Questions tagged [sqlcmd]
SQLCMD is Microsoft SQL Server's command line utility that allows you execute T-SQL commands from a command prompt.
181 questions
3
votes
1
answer
70
views
sqlcmd truncating "text" type column
I've noticed when using "sqlcmd" to connect to SQLServer, the text is cut off when the column is of "text" type and more than 256 characters.
I've discovered if I place "-y 0&...
2
votes
2
answers
451
views
Running sqlcmd errors
I am trying to run an MSSQL script using sqlcmd on Windows 10. The command is something like this:
sqlcmd -S "host" -U "user" -P "password" -d "database" -C -i &...
0
votes
1
answer
481
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 ...
1
vote
2
answers
203
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
180
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
373
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
1k
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
1
answer
342
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
1k
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
675
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
175
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
866
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
183
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
2k
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
3k
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.
...