Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Created .sql scripts from scripts
Message
 
 
À
20/01/2010 13:55:10
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Scripting
Versions des environnements
SQL Server:
SQL Server 2008
Divers
Thread ID:
01444928
Message ID:
01445063
Vues:
33
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--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform