|
-
May 19th, 2004, 10:57 AM
#1
SQL Syntax problem, please help
Hello all,
I was wondering if anyone knew why I was receiving the following error:
Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near 'spBobsTest%'.
Here is my SQL code:
/*
*****************************************************************************************
Author: Bob ********* *
Date Created: 05-17-04 *
Description: This procedure is designed to loop through all the databases on a server*
to look for any object. Specifically, at this point, you can modify the *
"Select Name" block to search for the object you desire *
*****************************************************************************************
*/
SET NoCount On
Declare @dbObject varChar(30)
Declare scroll_cursor Cursor For
Select Name
From master..sysDatabases
Where name like '%_app' OR
Name like '%_sys'
Order By name
Open scroll_cursor
FETCH NEXT FROM scroll_cursor INTO @dbObject
While (@@FETCH_STATUS = 0)
Begin
Exec ('IF EXISTS (select * from ' + @dbObject + '..sysObjects where name = ''spBobsTest%''')
Begin
SELECT 'Database Name: ' + @dbObject
End
FETCH NEXT FROM scroll_cursor INTO @dbobject
End
Close scroll_cursor
DEALLOCATE scroll_cursor
Thanks for any help you can offer!
Bob
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|