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.
| Author |
Topic |
|
chriskhan2000
Aged Yak Warrior
544 Posts |
Posted - 2005-03-21 : 12:48:51
|
| Can someone help me with this stored procedure. I'm trying to search to see if the value that the user entered exists or not. If not then in my asp.net page it will display msg, but if it do exists, then redirect them to the page detail section. Here's what I have but I don't think it's right.CREATE PROCEDURE CW_QUOTESEARCH@QUOTESEARCHID VARCHAR(10) = '',@QUOTESEARCH int OUTPUTASBEGIN SET @QUOTESEARCH = IsNull((select id from quote where id = @QUOTESEARCHID),0)ENDPlease advise. Thanks. |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-03-21 : 13:48:09
|
if exists(select id from quote where id = @QUOTESEARCHID)set @QUOTESEARCH = 1else set @QUOTESEARCH = 0Go with the flow & have fun! Else fight the flow |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2005-03-21 : 13:55:09
|
| And don't forget to use SELECT * with IF EXISTS and IF NOT EXISTS for performance reasons. It's the only time to use SELECT *.if exists(select * from quote where id = @QUOTESEARCHID)set @QUOTESEARCH = 1else set @QUOTESEARCH = 0 Tara |
 |
|
|
chriskhan2000
Aged Yak Warrior
544 Posts |
Posted - 2005-03-22 : 10:46:40
|
| Thanks both. GOt it now. |
 |
|
|
|
|
|