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 |
|
mapidea
Posting Yak Master
124 Posts |
Posted - 2009-09-08 : 01:47:58
|
| The following if else doesn't workALTER PROCEDURE [dbo].[test]@test varchar(20)ASSELECT tb_entry.[feature_id],tb_entry.[user_id]FROM [tb_profile_feature_entry] AS tb_entry IF @test="something"beginWHERE tb_entry.[user_id] = @testENDIs there is alternative to acheive the same result. |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-09-08 : 02:05:01
|
SELECT tb_entry.[feature_id],tb_entry.[user_id]FROM [tb_profile_feature_entry] AS tb_entry where (@test="something" and tb_entry.[user_id] = @test)or @test is null No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
mapidea
Posting Yak Master
124 Posts |
Posted - 2009-09-08 : 02:51:01
|
| Thanks Fred. |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-09-08 : 02:57:20
|
welcome  No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-09-08 : 04:09:00
|
| What if @test is not null?SELECT tb_entry.[feature_id],tb_entry.[user_id]FROM [tb_profile_feature_entry] AS tb_entry where (@test='something' and tb_entry.[user_id] = @test)or @test<>'something'MadhivananFailing to plan is Planning to fail |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-09-08 : 04:17:53
|
yes sir! No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|