Questions tagged [sqlcmd]
SQLCMD is Microsoft SQL Server's command line utility that allows you execute T-SQL commands from a command prompt.
182
questions
0
votes
1
answer
58
views
No logins showing under SQL Instance as admin and SA
I have an issue where when I log into SSMS I am not seeing any logins.
I am running as an administrator and logging in with SA.
It does not matter which account I log in with. I only ever see the two ...
0
votes
0
answers
48
views
Sqlcmd: The -W and the -y/-Y options are mutually exclusive
I am working on SQL server task. I need a sqlcmd result file with complete records with headers.
Here is the command and error message below
sqlcmd -S [Server_Name] -U [User_Name] -P [Password] -d [...
1
vote
0
answers
79
views
SQL script to run from batch jobs
I have a sql script that truncates the table and insert into database from a linked server.Since the server is SQL express I will need to use batch jobs to schedule the jobs. Below is a snippet of the ...
0
votes
0
answers
220
views
SQLCMD - Access is Denied After Running Script
I'm working with a vendor about this, but a supplied script that they have to run to upgrade their software, after running, ruins access to SQLCMD.
Before running the script I can open a Command ...
0
votes
1
answer
594
views
"Fatal scripting error" when parsing SQLCMD query
Similar issue seen here.
I am trying to run the following command from SSMS running in SQLCMD mode.
:r C:\dev\test scripts\sample.sql
But I get the following error:
A fatal scripting error occurred.
...
0
votes
0
answers
38
views
How to throw an error in SSDT Post-Deploy script to fail it's execution?
I'm using Microsoft SSDT to version DB schema. I have a script to autogenerate some triggers and i need to make sure that we don't forget to run it when tables change. I added a part to PostDeploy ...
0
votes
1
answer
139
views
Neatly print sp_help output similar to psql \d+
I've just been granted access to a SQL Server data warehouse and I'm trying to get to grips with sqlcmd. Coming from a Postgres/psql background, I'm used to being able to quickly look up a table ...
1
vote
0
answers
545
views
What is the relationship between sqlcmd and ODBC driver
I'm trying to install sql server 2022 on a build machine, and then test that I can connect to that server with sqlcmd. I previously had ODBC driver 17 and was getting errors from that command, so I ...
0
votes
1
answer
404
views
Failed to initialize sqlcmd library with error number -2147467259
This is my code:
SET @msg = 'Customer Voice replies.';
SET @query=
'SELECT [column1],[column2] FROM [StagingMX].[dbo].[_CVA]
WHERE DATEDIFF(day, [Completion time] ,GETDATE()) = 1
AND [...
0
votes
1
answer
152
views
Backup database on local pc
I am using this script to backup database on computer A:
sqlcmd -U MyDatabase -P MyPassword -S .\SQLEXPRESS -Q "EXEC sp_BackupDatabases @backupLocation = 'c:\shared', @databaseName='MyDatabase', @...
2
votes
2
answers
709
views
SQLCMD fails if -c; is specified in parameters on SQL Server 2019
The following sqlcmd fails with no error and no output, just returns silently.
SQLCMD -U dbuser -d dbname -w 255 -h-1 -P mypassword -S dbserver -Q "ALTER TABLE xyz ADD abcd NUMERIC(1)" -c;
...
0
votes
1
answer
147
views
Restoring SQL Server database on Windows instance from Linux SQLCMD
I have a SQL Server that is running under Windows. And I have a Linux client. AFAIK SQLCMD requires "local" (server-related) path to backup files. So the question is - how to specify windows ...
4
votes
2
answers
1k
views
Suppressing SQL Server Management Studio's 'Messages' from output of SQLCMD via SQL Server Agent
I've created a script that outputs data in an XML format, and was using SQL Server Agent (Job Step of Type 'Operating System (cmdexec)') to run a job monthly/quarterly to output the data to a specific ...
0
votes
2
answers
2k
views
Which install kit installs sqlcmd.exe?
I recently had to uninstall Visual Studio 2012 and DTS, then install VS 2017 and DTS again. Afterwards, The directory containing sqlcmd.exe was not in my PATH variable. I installed the following.
...
0
votes
1
answer
254
views
How do I stop SQLCMD from misinterpreting variable parameters?
I have a server config script we call with SQLCMD that runs a lot of other scripts in a folder, using :R \\folder\path\script.sql.
One of those scripts creates an Agent job that has a TSQL step that ...