Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Deploying Scripts with SQLCMD


Deploying Scripts with SQLCMD

Author
Message
David.Poole
David.Poole
SSCarpal Tunnel
SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)

Group: General Forum Members
Points: 4399 Visits: 3177
Comments posted to this topic are about the item Deploying Scripts with SQLCMD

LinkedIn Profile

Newbie on www.simple-talk.com
Adam Aspin
Adam Aspin
SSC Veteran
SSC Veteran (241 reputation)SSC Veteran (241 reputation)SSC Veteran (241 reputation)SSC Veteran (241 reputation)SSC Veteran (241 reputation)SSC Veteran (241 reputation)SSC Veteran (241 reputation)SSC Veteran (241 reputation)

Group: General Forum Members
Points: 241 Visits: 1032
Good stuff!

Have you ever had the (mis)fortune to use MSbuild too?

Adam
kuldipMCA
kuldipMCA
SSC Rookie
SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)

Group: General Forum Members
Points: 30 Visits: 144
Fatal scripting error. Cannot open connection specified in the SQLCMD script.
Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.

i got like that error when i do connect with the use of the sqlcmd.
Jim Russell-390299
Jim Russell-390299
Mr or Mrs. 500
Mr or Mrs. 500 (511 reputation)Mr or Mrs. 500 (511 reputation)Mr or Mrs. 500 (511 reputation)Mr or Mrs. 500 (511 reputation)Mr or Mrs. 500 (511 reputation)Mr or Mrs. 500 (511 reputation)Mr or Mrs. 500 (511 reputation)Mr or Mrs. 500 (511 reputation)

Group: General Forum Members
Points: 511 Visits: 1403
Excellent!
I have reached the stage in life where if it isn't scripted, I screw it up. How nice to learn about yet another scripting strategy.
yordan.georgiev
yordan.georgiev
Grasshopper
Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)

Group: General Forum Members
Points: 15 Visits: 47
for the most bravest here is a perl script to run multiple sql scirpts ...

requirement: the scirpts should be numbered:
1.RUN.scriptname.sql
2.RUN.scriptName2.sql
3...
n. RUN.scirptname3.sql

and placed in the same directory as the perl script

You can create a command line executable for it ( does not required Perl on the running machine ) with par or perl2exe ...

Anybody interested in ... I could put a link for binary download it ...

Grab the source at :

http://ysgitdiary.blogspot.com/2009/03/perl-script-to-run-sql-scripts-for-sql.html


Comments , shouts boos etc. would be highly appreciated .. .
R M Buda
R M Buda
SSC Veteran
SSC Veteran (211 reputation)SSC Veteran (211 reputation)SSC Veteran (211 reputation)SSC Veteran (211 reputation)SSC Veteran (211 reputation)SSC Veteran (211 reputation)SSC Veteran (211 reputation)SSC Veteran (211 reputation)

Group: General Forum Members
Points: 211 Visits: 300
Great article, David.
I had not seen examples of the error and standard outputs before.


Kuldip: it looks as though your windows login does not have windows integrated access to the server. You need to supply a SQL user name and password as part of the SQLCMD connect command or on the command line.

kuldip.bhatt (3/24/2009)
Fatal scripting error. Cannot open connection specified in the SQLCMD script.
Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.

i got like that error when i do connect with the use of the sqlcmd.

kuldipMCA
kuldipMCA
SSC Rookie
SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)

Group: General Forum Members
Points: 30 Visits: 144
how i give the usrename and password in the sql command?

:setvar Maindbserver "NHSserver"
:setvar Maindb "NHS_031209"
:Connect $(Maindbserver)
go
$ maindb

this is my code.

in this script how i can give user name and password?

My question is if diff servers has diffrent password then
what is the solution for this.

you must give Password and usrename.
Phil Factor
Phil Factor
SSC Eights!
SSC Eights! (933 reputation)SSC Eights! (933 reputation)SSC Eights! (933 reputation)SSC Eights! (933 reputation)SSC Eights! (933 reputation)SSC Eights! (933 reputation)SSC Eights! (933 reputation)SSC Eights! (933 reputation)

Group: General Forum Members
Points: 933 Visits: 2953
OOh yes. SQLCMD! I agree wholeheartedly that it is an essential for quickly automating complex processes across several servers. I love it. It is so good that one is tempted to keep it to oneself, and amaze people with one's wizardry.

Robyn and I wrote a workbench a while back which might help as a follow-up to David's excellent introduction. The SQLCMD workbench

I notice that the SQL Server 2008 version of SQLCMD is very similar to that of SQL Server 2005. Have they improved anything, or is SQLCMD one of those tools they have left to fester?


Best wishes,

Phil Factor
Simple Talk
alen teplitsky
alen teplitsky
SSCommitted
SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)

Group: General Forum Members
Points: 1805 Visits: 4626
good stuff, we're not under the same constraints here but using this we can build a deployment pack and execute it. the way it is now it's a manual process of running different scripts as specified by dev
David.Poole
David.Poole
SSCarpal Tunnel
SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)

Group: General Forum Members
Points: 4399 Visits: 3177
kuldip.bhatt (3/24/2009)
how i give the usrename and password in the sql command?

:setvar Maindbserver "NHSserver"
:setvar Maindb "NHS_031209"
:Connect $(Maindbserver)
go
$ maindb




:connect $(Maindbserver) -U YourUserName -P YourPassword

Personally I would avoid SQL standard security for scripts like the plague. It would mean you have a clear text file with credentials exposed.

LinkedIn Profile

Newbie on www.simple-talk.com
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search