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
Tag Archives: SQLCMD
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
:OUT /STDERR/STDOUT SQLCMD Command
:OUT <filename>/STDERR/STDOUT This command redirects all query results output that by default gets sent to standard output.
:r SQLCMD Command
:r <filename> This option enables the script writer or interactive user to read the contents of a specified script file and include it in the current execution session. The included file is processed in-place; in other words, every command encountered … Continue reading
Mix SQLCMD command with T-SQL statements in the same batch
It is safe to mix SQLCMD command with T-SQL statements in the same batch because they all get pre-processed before T-SQL is submitted to tor any given batch, all SQLCMD commands are pre-processed and only after that is T-SQL sent … Continue reading
Automate Backup Process With SQLCMD
Automate Backup Process — can create SQL Scheduled Task that will call and execute this SQL (everynight for example) declare @Dt_DateAndTime Varchar(100), @backupfile sysname, DECLARE @ThreeDaysAgo VARCHAR(50) select @Dt_DateAndTime = convert(char(8), getdate(), 112)+”+ Replace(convert(char(12), getdate(), 14),’:’,”) select @Dt_DateAndTime select @backupfile … Continue reading
SQLCMD Command Overview
As mentioned earlier, in addition to command line options, SQLCMD also supports many powerful commands. A SQLCMD command always starts with a new line and is preceded by a colon. A colon is required to make a clear distinction between … Continue reading