Author |
Topic |
kwacz23
Starting Member
44 Posts |
Posted - 2013-08-12 : 09:44:24
|
Hi I would like to add one more condition in below query. This highlighted part is not working. Could you help me with that ?@Country nvarchar(10)IF (@Country = 'ES' OR @Country = 'PT')SELECT 'Win 7 64 bit'IF (country ='FR')select 'win test'ELSESELECT 'Win 7 32 bit'UNIONSELECT 'Win 7 64 bit' |
|
MuMu88
Aged Yak Warrior
549 Posts |
Posted - 2013-08-12 : 10:14:12
|
I am not sure about the logic, but here is how you can fix the syntax:[CODE]IF (@Country = 'ES' OR @Country = 'PT')SELECT 'Win 7 64 bit'ELSEIF (@country ='FR')select 'win test'ELSESELECT 'Win 7 32 bit'UNIONSELECT 'Win 7 64 bit'[/CODE] |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2013-08-12 : 10:15:06
|
IF (@country ='FR') Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA |
|
|
ScottPletcher
Aged Yak Warrior
550 Posts |
Posted - 2013-08-12 : 14:38:07
|
To me, this style is easier to code, follow and, esp. maintain:SELECT CASE WHEN @Country IN (N'ES', N'PT') THEN 'Win 7 64 bit' WHEN @country IN (N'FR') THEN 'win test' ELSE 'Win 7 32 bit' END AS Win_Version |
|
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-08-13 : 00:26:32
|
[code]DECLARE @Country varchar(10) = 'India'SELECT CASE WHEN @Country IN (N'ES', N'PT') THEN 'Win 7 64 bit' WHEN @country IN (N'FR') THEN 'win test' ELSE 'Win 7 32 bit, Win 7 64 bit' END AS Win_VersionIf you wish to use IF...ELSE statement only, then follow MuMu88's postDECLARE @Country varchar(10) = 'India'IF (@Country in ( 'ES', 'PT')) SELECT 'Win 7 64 bit'ELSE IF (@country ='FR') SELECT 'win test'ELSE SELECT 'Win 7 32 bit' UNION SELECT 'Win 7 64 bit'[/code]--Chandu |
|
|
kwacz23
Starting Member
44 Posts |
Posted - 2013-08-14 : 04:19:01
|
Thanks |
|
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-08-14 : 08:04:56
|
quote: Originally posted by kwacz23 Thanks
welcome--Chandu |
|
|
sivadss2007
Starting Member
18 Posts |
Posted - 2013-08-28 : 09:04:24
|
@Country nvarchar(10)IF (@Country = 'ES' OR @Country = 'PT')SELECT 'Win 7 64 bit'IF (@country ='FR')select 'win test'ELSESELECT 'Win 7 32 bit'UNIONSELECT 'Win 7 64 bit'P.Siva |
|
|
ShivaKrishna
Starting Member
20 Posts |
Posted - 2013-08-28 : 09:54:22
|
SELECT CASE WHEN @Country IN ('ES', 'PT') THEN 'Win 7 64 bit' WHEN @country ='FR' THEN 'win test' ELSE 'Win 7 32 bit' END AS Win_Version |
|
|
|