Sqlcmd is the SQL Server 2005 replacement for osql which in turn is being deprecated in SQL Server 2005. An irritating aspect of osql is that it lacks basic macro facilities. A macro processor like M4 could be used to preprocess the script but that required deploying M4. So I was excited when I learnt that sqlcmd had macro like features built-in and I could more often avoid writing code like:
declare @attributesSchema as xml
set @attributesSchema = (select * from openrowset(bulk 'C:\Source\Program Database\Attributes.xsd', single_nclob) as [file])
create xml schema collection [Program].[Attributes] as @attributesSchema
Sqlcmd adds support for :commands which give you much of the functionality of a macro language. Some of the most interesting :commands are:
There is a sqlcmd mode in Management Studio that works with all these :commands except for :perftrace. There are several other interesting commands listed in the documentation and an alphabet soup of command options.
A nice new command option is:
Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm
This posting is provided "AS IS" with no warranties, and confers no rights.