Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Created .sql scripts from scripts
Message
 
 
To
20/01/2010 13:55:10
General information
Forum:
Microsoft SQL Server
Category:
Scripting
Environment versions
SQL Server:
SQL Server 2008
Miscellaneous
Thread ID:
01444928
Message ID:
01445063
Views:
32
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.
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform