patternsqlMinor
Suppress database change message in SQLCMD.exe
Viewed 0 times
exemessagedatabasesqlcmdsuppresschange
Problem
I am writing a script generation script.
The script is generating list of DDL statments.
The
Since this is a very long script, with unknown length.
We use
The generated scripts
The problem is the generated script
I need assistance to suppress
Using SSMS
But we cannot run
Please asvise how to suppress
The script is generating list of DDL statments.
The
util_generator.sql generation starts with database connection:USE [TARGET_DATABASE]
GO
...
Many queries
Followed by print statements
...Since this is a very long script, with unknown length.
We use
SQLCMD.exesqlcmd -s sa\password -i util_generator.sql -r0 -o util_1.sqlThe generated scripts
util_1.sql looks something like this:Changed database context to 'TARGET_DATABASE'.
CREATE TABLE ...
CREATE INDEX ...
CREATE VIEW ...The problem is the generated script
util_1.sql fails on unknown command Changed database context to 'TARGET_DATABASE'.I need assistance to suppress
Changed database context to 'TARGET_DATABASE'. message from SQLCMD.exeUsing SSMS
util_generator.sql works good not producing any Changed database context to 'TARGET_DATABASE'. message.But we cannot run
util_generator.sql on SSMS from CLI for unknown length output scripts.Please asvise how to suppress
Changed database context to 'TARGET_DATABASE'. statement in SQLCMD.exeSolution
You can suppress (error) messages with a severity level lower than 10. Add -m10 as startup option.
to the best of my knowledge, there is no direct way for SQLCMD to suppress that particular message. But perhaps suppressing info-type messages (as per above) will cut it?
Or, of course, use the -d switch as suggested by Dudi.
to the best of my knowledge, there is no direct way for SQLCMD to suppress that particular message. But perhaps suppressing info-type messages (as per above) will cut it?
Or, of course, use the -d switch as suggested by Dudi.
Context
StackExchange Database Administrators Q#252495, answer score: 3
Revisions (0)
No revisions yet.