Sqlcmd to generate file without dashed line under header, without row count

Solutions: 1) To remove the row count (“(139 rows affected)”) you should use SET NOCOUNT ON statement. See ref. 2) To remove column headers you should use -h parameter with value -1. See ref (section Formatting Options). Examples: C:\Users\sqlservr.exe>sqlcmd -S(local)\SQL2012 -d Test -E -h -1 -s, -W -Q “set nocount on; select * from dbo.Account” … Read more

Docker + mssql-server-linux: How to launch .sql file during build (from Dockerfile)

I ended up using a slightly modified version of VDR’s solution which waits for the sqlservr to start by checking the logs instead of sleeping 10 seconds: RUN ( /opt/mssql/bin/sqlservr –accept-eula & ) | grep -q “Service Broker manager has started” \ && /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P ‘P@ssw0rd’ -i /opt/mssql-scripts/000_create_db.sql \ && pkill … Read more

SqlServer 08: Query to list all databases in an instance?

sqlcmd -E -S SERVER\INSTANCE -Q “sp_databases” Notes: -E: Use a trusted connection (“Windows authentication”). Replace by -U username -P password for SQL Server authentication. -S SERVER\INSTANCE: The instance of SQL Server to which to connect. If you don’t know the name of your instance, you can use sqlcmd -L to get a list. -Q: The … Read more

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)