Pages
Tags
:ERROR SQLCMD Command :LIST SQLCMD Command :LISTVAR SQLCMD Command :ON ERROR :ON ERROR SQLCMD :PERFTRACE SQLCMD :PERFTRACE SQLCMD Command :XML :XML SQLCMD Command :XML [ON/OFF] SQLCMD Command Automate Backup with SQLCMD CMD command CMD list of the servers OPENROWSET OPENROWSET excel file OSQL RESET SQLCMD command SERVERLIST SERVERLIST SQLCMD Command SQLCMD SQLCMD Backup SQLCMD Batch SQLCMD command SQLCMD list of the servers SQLCMD Script SQLCMD Scripting Variables SQLCMD Startup Script sqlcmd stored proc SQLCMD T-SQL SQLCMD Variables Startup Script stored procedure sqlcmd XP_CMDSHELL XP_CMDSHELL excel file XP_CMDSHELL SQL 2000 XP_CMDSHELL SQL 2005 XP_SMDSHELL [:]ED SQLCMD Command [:]EXIT[(statement)] SQLCMD Command [:]QUIT SQLCMD CommandCategories
Author Archives: admin
Create Excel File Using OPENROWSET and XP_CMDSHELL
Create Excel File Using OPENROWSET and XP_CMDSHELL Create PROCEDURE MCA_SP_CREATE_EXCEL @File_Name as varchar(50) = ” AS BEGIN SET NOCOUNT ON declare @File_Name as varchar(50) DECLARE @Cmd varchar(1000) DECLARE @fn varchar(500) DECLARE @provider varchar(100) DECLARE @ExcelString varchar(100) – New File Name … Continue reading
Posted in Uncategorized
Tagged OPENROWSET, OPENROWSET excel file, XP_CMDSHELL, XP_CMDSHELL excel file
Leave a comment
Using XP_CMDSHELL on SQL Server 2005
So in order to use xp_cmdshell whether you are a sysadmin or a regular user you need to first enable the use of xp_cmdshell. Doing this is similar to what was done when enabling the dedicated administrator connection. This can … Continue reading
What is XP_CMDSHELL
XP_CMDSHELL – extended stored procedure. With this extended stored procedure you have the ability to run any command line process within your SQL script, so you can embed this within your stored procedures, jobs or batch processing. In SQL Server … Continue reading
Posted in Uncategorized
Tagged XP_CMDSHELL, XP_CMDSHELL SQL 2000, XP_CMDSHELL SQL 2005
Leave a comment
Examples of XP_SMDSHELL Commands
1) XP_CMDSHELL Directory Search Let’s start out with a simple directory search example. Say you do not have access to the physical SQL Server machine, but you want to see all the files in the “C:\temp” directory that have a … Continue reading
XP_CMDSHELL – Extended Stored Procedure
“xp_cmdshell” is an extended stored procedure provided by Microsoft and stored in the master database. This procedure allows you to issue operating system commands directly to the Windows command shell via T-SQL code. If needed the output of these commands … Continue reading
SQLCMD Startup Script
SQLCMD can run a startup script defined by the environment variable SQLCMDINI. Suppose you want to always execute the following query when you are connected to the server: SELECT @@SERVERNAME, @@VERSION Place this command inside the init.sql file and define … Continue reading
SQLCMD Scripting Variables
It’s a good idea to discuss scripting variables at this point before discussing different SQLCMD commands, primarily because certain commands reveal their true power only via leveraging scripting variables. SQLCMD variables are different from T-SQL variables in many aspects. The … Continue reading
:XML [ON/OFF] SQLCMD Command
:XML [ON/OFF] When you expect XML data to be coming back from the server, for example because of a FOR XML clause in your query, you should set XML mode to ON via this command, to properly format the output. … Continue reading
Posted in Uncategorized
Tagged :XML, :XML [ON/OFF] SQLCMD Command, :XML SQLCMD Command
Leave a comment
:ON ERROR [exit/ignore] SQLCMD Command
:ON ERROR [exit/ignore] This command instructs SQLCMD on how to handle errors during script execution. The following options are available: * exit Exits the program with the appropriate error value * ignore Ignores the error and continues execution. An error … Continue reading
:PERFTRACE /STDERR/STDOUT SQLCMD Command
ERFTRACE <filename>/STDERR/STDOUT The ERFTRACE command redirects all performance information (see the discussion of the -p option) that by default goes to standard output.
Posted in Uncategorized
Tagged :PERFTRACE SQLCMD, :PERFTRACE SQLCMD Command, SQLCMD command
Leave a comment