Description
I use SQLCMD since many years to launch scripts on Microsoft WSUS databases (WID) like backup, shrink, etc.
Sinc some years I used the SQLCMD from "SQL Command Line Utilities 15" (MsSqlCmdLnUtils64.msi) and I never had issue. Everything is working fine.
I decided to move with SqlCmd 1.5.0 (latest vesion) to be up-to-date, security fixes. But he didn't work.
Due to a WID database limitation where it's not work in network and need administrator elevation, with old SqlCmd.exe I work like that:
1- Open a Command Line in elevation mode
2- Go to the SqlCmd Binn folder (C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\SQLCMD.exe). Version 15.0.2000.5
3- Type the command line to run my action. In this sample I will run a T-SQL script to shrink the database:
sqlcmd -S np:\.\pipe\MICROSOFT##WID\tsql\query -i "C:\script\shrink.sql" -o "C:\Script\shrink.log"
The content of the shrink.sql is:
USE [SUSDB]
GO
DBCC SHRINKDATABASE(N'SUSDB')
GO
DBCC SHRINKFILE(N'SUSDB', 0, TRUNCATEONLY)
GO
4- Everything work fine ! The database and files are shrinked !!!
If I install SqlCmd 1.5.0, I run the same command line, The I got in the log file:
Access denied
Access denied
It seem SqlCmd 1.5.0 have difficulties to connect.