Are you running with SET NOCOUNT ON?
Also, did you see the suggestion I posted?
>No I didn't - thanks I will.
>
>One problem I just noticed :
>
>I am running xp_cmdshell from master.
>
>the script does an explicit USE of the Membership database before it gets the list of indexes
>
>The output script, before it gets to the DROP lines created, has a line
>
>Changed database context to 'membership'.
>
>which will, of course, error when I try to run the .SQL script. Is there a way to suppress that line as part of the output ?
>
>
>
>I am runnin
>>Did you try
>>
>>-S (local)
>>
>>
>>>Okay, here's what I have so far and it's working nicely.
>>>
>>>( as you said I had to enable xp_cmdshell first )
>>>
>>>
>>>DECLARE @source VARCHAR(200)
>>>DECLARE @result VARCHAR(200)
>>>DECLARE @cmd VARCHAR(200)
>>>
>>>SET @source = '"C:\PDS\Create Drop all indexes.sql"'
>>>SET @result = '"C:\PDS\Drop all Membership indexes.sql"'
>>>
>>>SET @cmd = 'SqlCmd -E -S HARRY-WIN7 -i '+@source+ ' -o ' +@result
>>>
>>>EXEC master..xp_cmdshell @cmd;
>>>
>>>
>>>
>>>When this completes I have exactly what I want in the result .sql file.
>>>
>>>For lurkers : two tricky spots - be sure to use -E param so you see errors - I needed to be sure output was going to a folder that SQL server had permission to use
>>>
>>>The server must be name explicitly - local won't do it
>>>
>>>But this just opened a whole new world for me in using T-SQL. I love the idea of writing scripts that write scripts and now being able to 'automate' the drudge part has real potential for what I'm working on.
>>>
>>>Thanks to Serge and Naomi for your help. As I make more progress with this I'll post my results.
If it's not broken, fix it until it is.
My Blog