My Blog List

hotinit.com. Powered by Blogger.

Search This Blog

xp_cmdshell

Monday, 8 August 2011

This a best method to invoke command prompt through a stored Procedure

Syntax

EXEC xp_cmdshell 'Command as parameter'

To execute a command and to return an output use this method



EXEC xp_cmdshell 'dir *.exe'

To execute a command and not to return an output use the following method
EXEC xp_cmdshell 'dir *.exe', NO_OUTPUT


Example:----
DECLARE @result int
EXEC @result = xp_cmdshell 'dir *.exe'
IF (@result = 0)
   PRINT 'Success'
ELSE
   PRINT 'Failure'


Removing char(10) or Enter or Return in Excell Cells or Spreadsheet

Friday, 5 August 2011

Create a Macro, Put the below code and run it
  1. Copy above code.
  2. In Excel press Alt + F11 to enter the VBE.
  3. Press Ctrl + R to show the Project Explorer.
  4. Right-click desired file on left (in bold).
  5. Choose Insert -> Module.
  6. Paste code into the right pane.
  7. Press Alt + Q to close the VBE.
  8. Save workbook before any other changes.
Navigate to the worksheet on which you want to run the code, and hit Tools-->Macro, Macros, and double-click RemoveRtns.


Option Explicit  
Sub RemoveRtns()
Dim cel As Range 
For Each cel In ActiveSheet.UsedRange  
cel = Replace(cel, Chr(10), " ") 
Next 
End Sub









 

Blogger news

Blogroll

Most Reading

8.6/10