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
 SQL Server Development (2000)
 Need help with if EXISTS in stored proc

Author  Topic 

smithsf22
Starting Member

9 Posts

Posted - 2006-12-06 : 18:23:32
Hello,
I am trying to make a stored proc that will tell me if there are any rows in a table. The table name is a variable that I get at the start of the proc it is not sent in. What I am looking for in the table is sent into the stored proc.

here is what i have so far but it does not work, i can not save it. It does not seem to allow me to use the if exists with variables.

if exists (SELECT * FROM + @TableName + WHERE + @ColumnName + = + @SearchStr2)

print 'got here ' +@TableName + ' '+ @ColumnName

END

Thanks for any help

timmy
Master Smack Fu Yak Hacker

1242 Posts

Posted - 2006-12-06 : 19:21:45
You're right - it won't.

Are you looking for a row count for the given table/search criteria?
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-12-06 : 23:47:52
www.Sommarskog.se/Dynamic_sql.html

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -