How to pass in parameters to a SQL Server script called with sqlcmd?

Use the -v switch to pass in variables. sqlcmd -v varMDF=”C:\dev\SAMPLE.mdf” varLDF=”C:\dev\SAMPLE_log.ldf” Then in your script file CREATE DATABASE [SAMPLE] ON PRIMARY ( NAME = N’SAMPLE’, FILENAME = N’$(varMDF)’ , SIZE = 23552KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB ) LOG ON ( NAME = N’SAMPLE_log’, FILENAME = N’$(varLDF)’ , SIZE = 29504KB , … Read more

How to properly manage database deployment with SSDT and Visual Studio 2012 Database Projects?

I’ve been working on this myself, and I can tell you it’s not easy. First, to address the reply by JT – you cannot dismiss “versions”, even with declarative updating mechanics that SSDT has. SSDT does a “pretty decent” job (provided you know all the switches and gotchas) of moving any source schema to any … Read more

How do I grant myself admin access to a local SQL Server instance?

Open a command prompt window. If you have a default instance of SQL Server already running, run the following command on the command prompt to stop the SQL Server service: net stop mssqlserver Now go to the directory where SQL server is installed. The directory can for instance be one of these: C:\Program Files\Microsoft SQL … Read more