database installation scripts | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

database installation scripts

I’ve worked for some time with Oracle.
To script our tables (creation, default data,…) we had serveral sql files (one for each creation and filling of each table). We had one "master sql file" that called all those files. It was very easy with our sqlplus command line tool to connect to the database, type the name of the master script file, and then all required other scripts were called to configure our database and tables. Now, client asks to port our application to sql server 2005, and i am new with that.
What is the way of working in such a case? (in sql server 2005 i’ve worked with querry analyser, but it would be a lot of work to open and execute each script).
You could use SQLCMD in the same fashion. ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/sqlcmpt9/html/e1728707-5215-4c04-8320-e36f161b834a.htm
for more info on this utility. /Kenneth
yes, i found that already, but it seems this tool does not work.
i see nothing after my querries. no results, and even no errormessages. C:>sqlcmd
1> select * from TestSrc.dbo.Ships;
2> "select * from TestSrc.dbo.Ships;"

It works in an interactive way. You can keep on typing several rows, pressing enter at each row, but it won’t be sent until you type GO &lt<img src=’/community/emoticons/emotion-4.gif’ alt=’;p’ />ress enter&gt;<br /><br />GO is the batchterminator, which tells sqlcmd that input is now finished, send it to the server.<br /><br />/Kenneth
and how can i make my output more "readable" in the cmd console. when i do this:
sqlcmd -q "select names from TestSrc.dbo.Ships;" -o C:eek:.txt
and i open the file, i see the output is readable (but i don’t know why, but each line is filled with around 4000 spaces; probably that’s the reason why the output is unreadable in the cmd) can i make my output more "readable" in the cmd console ?

You can run SQLCMD scripts in SSMS QUERY WINDOW by changing the window to run SQLCMD mode.
Your output will be very much readable and you see the errors in red… Editing SQLCMD Scripts with Query Editor
Moderator All postings are provided “AS IS” with no warranties for accuracy.

ha, i found it myself how to remove all spaces. startup cmd with the following options:
c:sqlcmd -W but the reason for sqlcmd trailing each result with spaces is still unknown to me.
quote:You could use SQLCMD in the same fashion.

for the master script file, i have to use a .bat file or am i wrong? (and in the bat file, for each script:
sqlcmd -i c:script1.sql
sqlcmd -i c:script2.sql
sqlcmd -i c:script3.sql
… is this the best approach?

Yes, you can use batch file…and it is best approach… MohammedU.
Moderator All postings are provided “AS IS” with no warranties for accuracy.

Because the scripts are used in a batch file the default behaviour of MSDOS puts spaces. Satya SKJ
Microsoft SQL Server MVP
Writer, Contributing Editor & Moderator
This posting is provided AS IS with no rights for the sake of knowledge sharing. The greatest discovery of my generation is that a human being can alter his life by altering his attitudes of mind.