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 123»»»

Deploying Scripts with SQLCMD Expand / Collapse
Author
Message
Posted Tuesday, March 24, 2009 12:35 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: 2 days ago @ 1:30 AM
Points: 2,898, Visits: 1,795
Comments posted to this topic are about the item Deploying Scripts with SQLCMD

LinkedIn Profile
Newbie on www.simple-talk.com
Post #682097
Posted Tuesday, March 24, 2009 2:40 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Wednesday, July 30, 2014 3:20 AM
Points: 81, Visits: 900
Good stuff!

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

Adam
Post #682139
Posted Tuesday, March 24, 2009 5:11 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Wednesday, July 9, 2014 5:06 AM
Points: 22, Visits: 106
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.
Post #682197
Posted Tuesday, March 24, 2009 5:13 AM
SSC-Addicted

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

Group: General Forum Members
Last Login: Friday, July 30, 2010 11:27 AM
Points: 435, Visits: 1,403
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.
Post #682198
Posted Tuesday, March 24, 2009 5:31 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, March 28, 2011 12:09 PM
Points: 7, 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 .. .
Post #682207
Posted Tuesday, March 24, 2009 6:00 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, May 8, 2014 6:02 AM
Points: 146, Visits: 238
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.
Post #682220
Posted Tuesday, March 24, 2009 6:07 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Wednesday, July 9, 2014 5:06 AM
Points: 22, Visits: 106
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.

Post #682227
Posted Tuesday, March 24, 2009 6:27 AM


Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Today @ 7:03 AM
Points: 579, Visits: 2,519
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
Post #682239
Posted Tuesday, March 24, 2009 6:59 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, July 17, 2014 12:34 PM
Points: 1,414, Visits: 4,539
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

https://plus.google.com/100125998302068852885/posts?hl=en
http://twitter.com/alent1234
x-box live gamertag: i am null
[url=http://live.xbox.com/en-US/MyXbox/Profile[/url]
Post #682270
Posted Tuesday, March 24, 2009 7:28 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: 2 days ago @ 1:30 AM
Points: 2,898, Visits: 1,795
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
Post #682306
« Prev Topic | Next Topic »

Add to briefcase 123»»»

Permissions Expand / Collapse