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 |
shanmugaraj
Posting Yak Master
219 Posts |
Posted - 2013-03-26 : 06:25:02
|
Kindly help me with the if else part on below SPCREATE PROCEDURE [dbo].[usp_get_data] ( @poi [nvarchar](10) = NULL)ASBEGINIF @poi = NULL Then SELECT poi_category from poi_masterelse SELECT poi_category from poi_master where poi_code =@poiend ifENDTHANKSSHANMUGARAJnshanmugaraj@gmail.com |
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-03-26 : 06:36:39
|
BEGINIF @poi IS NULL Then SELECT poi_category from poi_masterelseSELECT poi_category from poi_master where poi_code =@poiend ifENDremove the striked keywords and make sure IS operator instead of = operator |
|
|
shanmugaraj
Posting Yak Master
219 Posts |
Posted - 2013-03-26 : 07:12:20
|
can i write as concordinating query like where in i can save space and timeBEGINstrsql = "SELECT poi_category from poi_master"IF @poi IS NOT NULL Then strsql = strsql + "where poi_code =@poi"end ifexec strsqlENDTHANKSSHANMUGARAJnshanmugaraj@gmail.com |
|
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-03-26 : 07:29:08
|
SELECT poi_Category FROM poi_masterWHERE poi_code = @poi OR @poi IS NULL |
|
|
shanmugaraj
Posting Yak Master
219 Posts |
Posted - 2013-03-26 : 08:15:52
|
Thanks bandiTHANKSSHANMUGARAJnshanmugaraj@gmail.com |
|
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-03-26 : 08:21:01
|
quote: Originally posted by shanmugaraj Thanks bandiTHANKSSHANMUGARAJnshanmugaraj@gmail.com
Welcome--Chandu |
|
|
|
|
|