SQL Server Performance

How can we use spool in sql server 2005

Discussion in 'Getting Started' started by jagpalsingh4, Mar 3, 2008.

  1. jagpalsingh4 New Member

    Hello,
    Can any body help me that how can i use spool in sql server 2005 i dont want to use management studio to run this query i want some scheduler to run this query everymonth automatically .
    select name ,'current_date'=getdate (),size*8/1024,@@servername as servername
    from sys.database_files
    plz help me
    Regards
    Jagpal singh
  2. satya Moderator

    Have you heard about SQL Server Agent?
    It will do much of these kind of scheduling tasks for you!
  3. jagpalsingh4 New Member

    but how can i attach this query in scheduler
    select name ,'current_date'=getdate (),size*8/1024,@@servername as servername
    from sys.database_files
  4. satya Moderator

  5. jagpalsingh4 New Member

    hello,
    Actually we need this query result in file i dont want to run this query manually everytime bcause we are dealing with 10 to 12 servers so we need this query result in file .like we do in oracle (spool)to check that how much size is increazing and all details.#select name ,'current_date'=getdate (),size*8/1024,@@servername as servername
    from sys.database_files
    thaxxxxxxxx
  6. Adriaan New Member

    Check out the bcp command in Books Online - it is an ugly old-school command-line utility, and it may require a few refinements to make it work for your various databases. You can save the bcp script as a stored procedure, and schedule a job to execute this at whichever interval you may need.
    Other than that, I would recommend that you look at Satya's recommendations.
  7. satya Moderator

    Hey Adriaan, BCP is not ugly old-school rather say the golden provision for the DB users to insert data efficiently without complaining much about SQL alone [;)].
  8. jagpalsingh4 New Member

    Hello ,
    satya thaxx for replying me i have done by sqlcmd
    sqlcmd -S (local) -E -y -d master -i f:jagpalsql.sql -o f:jagpalsqlsql.txt

    copy /y dbastats.txt temp.txt
    copy /Y temp.txt + sqlsql.txt dbastats.txt
    thaxx
    regards
    jagpalsingh
  9. Adriaan New Member

    <P mce_keep="true">[quote user="satya"] <P>Hey Adriaan, BCP is not ugly old-school rather say the golden provision for the DB users to insert data efficiently without complaining much about SQL alone <IMG alt=Wink src="http://sql-server-performance.com/Community/emoticons/emotion-5.gif">. </P>[/quote]The only use I've had for BCP was for dumping results to text files, and it usually involved dynamic SQL to&nbsp;compile the BCP command line. Be honest - it doesn't get much uglier than that, with all the switches and single quotes and double qoutes.[:p]

Share This Page