|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
use go on varriableHow can i use go on multiline statement, I would like to create job step which contains go in it. But i can not create. I try to use something like this EXEC sp_add_jobstep @job_name = N'Audit_Log Truncate', @step_name = N'AG Audit Log Truncate', @subsystem = N'TSQL', @command = N' use adminsys_SIPP_AIG Go if exists (select * from sysobjects where name = ''audit_log'') truncate table audit_log Go use master <Go> DBCC SHRINKDATABASE (adminsys_SIPP_AIG) use adminsys_SIPP_AIG BACKUP LOG adminsys_SIPP_AIG with no_log DBCC SHRINKFILE (ADMINSYS_SIPP_AIG_log,10) ', @retry_attempts = 5, @on_success_action = 3, @on_fail_action = 3, @retry_interval = 5 ; GO Thanks in advance -- Thanks Ganesh Ganesh (gsgan***@yahoo.com) writes:
Show quote > How can i use go on multiline statement, I would like to create job step That certainly looks like a syntax error to me. Syntactially GO is just an> which contains go in it. But i can not create. I try to use something like > this > > EXEC sp_add_jobstep > @job_name = N'Audit_Log Truncate', > @step_name = N'AG Audit Log Truncate', > @subsystem = N'TSQL', > @command = > N' > use adminsys_SIPP_AIG > Go > if exists (select * from sysobjects where name = ''audit_log'') > truncate table audit_log > Go identifier as far as SQL Server is concerned. It could be the name of a table, stored procedure etc. GO as a batch separator is only something that is used by query tools. (So if you were to run this from, say, Query Analyzer, you would get an error immediately, because QA would cut the batch before the string terminates.) You can define for a job step which database it is to run in. And there is no need to switch to master to shrink the database. But even better: don't shrink the database at all. It's reasonable to shrink a database if you archived a lot of data that never will reappear, or if there has been some excessive operation. But it's a bad idea to shrink it, if will grow again. Autogrow is not cheap, and creates load on the system. -- Erland Sommarskog, SQL Server MVP, esq***@sommarskog.se Books Online for SQL Server 2005 at http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx Books Online for SQL Server 2000 at http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx > But even better: don't shrink the database at all. It's reasonable to Absolutely agree.> shrink a database if you archived a lot of data that never will reappear, > or if there has been some excessive operation. But it's a bad idea to > shrink it, if will grow again. Autogrow is not cheap, and creates load > on the system. For more info, Ganesh, see http://www.karaszi.com/SQLServer/info_dont_shrink.asp |
|||||||||||||||||||||||