Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
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: Wednesday, February 3, 2016 11:35 PM
Points: 486, Visits: 1,193
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 @ 6:41 PM
Points: 14,541, Visits: 38,384
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

--
help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!
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: Wednesday, February 3, 2016 11:35 PM
Points: 486, Visits: 1,193
Thanks..

Post #1376822
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse