Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

batch file script need Expand / Collapse
Author
Message
Posted Wednesday, October 24, 2012 9:18 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Yesterday @ 3:40 AM
Points: 431, Visits: 1,072
I need a batch file script to read the hostname, and replace the hostname dynamicaly where we see 'Hostname' in below script.

sqlcmd -S Hotsname\Inst -i C:\abc.sql


can some one provide this.
Post #1376546
Posted Wednesday, October 24, 2012 9:21 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 2:11 PM
Points: 12,922, Visits: 32,274
in a bat/cmd file or command prompt, you can get the computer name from the variable %computername%

echo %computername%
so you can build a script with that...does that help?

edit

also, if the script is alwasy being run on the same server, you don't need the computername anyway...you can just use the dot placeholder to reference the current server, i think
sqlcmd -S .\Inst -i C:\abc.sql



Lowell

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1376548
Posted Thursday, October 25, 2012 1:44 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Yesterday @ 3:40 AM
Points: 431, Visits: 1,072
Thanks..

Post #1376822
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse