SQL Server Performance

database installation scripts

Discussion in 'SQL Server 2005 General Developer Questions' started by stt, Apr 3, 2007.

  1. stt New Member

    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).

  2. Kewin New Member

    You could use SQLCMD in the same fashion.

    for more info on this utility.

  3. stt New Member

    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.

    1> select * from TestSrc.dbo.Ships;
    2> "select * from TestSrc.dbo.Ships;"

  4. Kewin New Member

    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
  5. stt New Member

    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 ?
  6. MohammedU New Member

    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


    All postings are provided “AS IS” with no warranties for accuracy.
  7. stt New Member

    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.

  8. stt New Member

    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?
  9. MohammedU New Member

    Yes, you can use batch file...and it is best approach...


    All postings are provided “AS IS” with no warranties for accuracy.
  10. satya Moderator

    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.

Share This Page