Problem:-
In
somehow we can’t find sqlcmd.exe location easily and that may be stress in a difficult situation like the down of one critical production server and for
that, I figure out a solution for that problem by running below script to find
where sqlcmd.exe in my server regardless of the location of SQL Server setup
files, commonly that used when using Windows Core as an OS with SQL Server.
I want to
point out that yes, we can use Powershell instead by using Invoke-sqlcmd cmdlet. I know not all of us
know Powershell and most of us do know T-SQL. Until that changes happen and I
expect it will 😃 SQLCMD
will be around.
Solution:-
By
copying n paste below script you can find out where the sqlcmd.exe exist
on our server regardless of the location of SQL Server setup files
Note:-
Maybe
take a long time depending on the number of files on your disk, don't worry it
workes perfect at the end 😃
Using Powershell:-
Next Step:-
Take the full path by copying
and connect to SQL Server using sqlcmd as you wish like below example
Example Using Powershell to run sqlcmd:-
Set-Location 'C:\Program Files\Microsoft SQL Server\Client
SDK\ODBC\130\Tools\Binn'
Ref:-
No comments:
Post a Comment