December 10, 2002 at 5:20 pm
The following query executes fine
EXEC('SELECT a.* FROM OPENROWSET(''SQLOLEDB'', ''' + 'Trusted_connection=yes;' + 'Server=' + @Server_name + ''', ''SELECT * FROM msdb.dbo.sysdbmaintplan_history'') AS a')
But if i try to use a where clause e.g. where activity = 'Backup Database', i'm receiving syntax errors. I'm messing up the quotes somehow. Can someone help me ?
December 10, 2002 at 7:13 pm
Try this
Select ('SELECT a.* FROM OPENROWSET(''SQLOLEDB'', ''Trusted_connection=yes;Server='
+ @@Servername
+''', ''SELECT * FROM msdb.dbo.sysdbmaintplan_history where activity = ''''Backup Database'''' '') AS a')
Exec('SELECT a.* FROM OPENROWSET(''SQLOLEDB'', ''Trusted_connection=yes;Server='
+ @@Servername
+''', ''SELECT * FROM msdb.dbo.sysdbmaintplan_history where activity = ''''Backup Database'''' '') AS a')
December 11, 2002 at 4:17 pm
Thanks numbers.
That works fine.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply