Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Error in the code

Author  Topic 

peter.mano
Starting Member

6 Posts

Posted - 2010-06-17 : 01:36:27
I am getting the following error "Unclosed quotation mark before the character string 'use databasename" for the below code. can someone help me out in this.?
The error appears in sql server 2000. Whereas in 2005 it works fine...

set @query ='use databasename
go
deny select on tablename to user
go
ALTER LOGIN [loginname] DISABLE
go
drop login [loginname]'


EXEC @ReturnCode = msdb.dbo.sp_add_jobstep @job_id=@jobId, @step_name=@stepname2,
@step_id=2,
@cmdexec_success_code=0,
@on_success_action=3,
@on_success_step_id=3,
@on_fail_action=4,
@on_fail_step_id=3,
@retry_attempts=0,
@retry_interval=0,
@os_run_priority=0, @subsystem=N'TSQL',
@command=@query,
@database_name=N'master',
@flags=0

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2010-06-17 : 04:19:58
You can set the @database_name parameter in the sp_add_jobstep instead, remove all the GO's, place all the statements on one line and separate them with a semicolon. Not so nice maybe but it should work.

- Lumbago

My blog (yes, I have a blog now! just not that much content yet)
-> www.thefirstsql.com
Go to Top of Page
   

- Advertisement -