Output string to text file?

  • I have a stored procedure that builds 'alter index rebuild .... ' statements with the online option if that is viable that is designed to run as a maintenance job. There are other variables in play such as fragmentation and number of rows in the table that determine whether or not the index gets rebuilt.

    With regards to the offline index rebuilds, we need to hit a specific maintenance window in a 24/7 environment. Right now, the proc just executes the statement via

    execute (@SQLStatment). Since the time needed to build the statments varies from day to day, it is proving difficult to hit the given window.

    So what I would like to do is send the @SQLStatment string to a Offline_index_maintenance.sql file that I could then call during the specified time.

    Thoughts? is there a better way to do this?

    Thanks for your time,

    Ken

  • why to a text file, and not a table in say, the msdb database, which can contain a suite of commands for you to run during you rmaintenance window?

    why must it be a file vs a row in a table?

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • It doesn't have to be, and now that you've said that I'm going to go kick myself for getting tunnel vision on a user request.

    Thanks!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply