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 |
Blessed1978
Yak Posting Veteran
97 Posts |
Posted - 2014-04-09 : 21:36:37
|
is this a correct syntax to populate a files name PHONEScase when(d.phone = (SELECT phone from CALLS where exists(select home_phone, mobile, toll_free from CALLS2) Then 1 END 'PHONES' |
|
VeeranjaneyuluAnnapureddy
Posting Yak Master
169 Posts |
Posted - 2014-04-10 : 00:58:38
|
case when d.phone IN (SELECT phone from CALLS where exists(select home_phone, mobile, toll_free from CALLS2)) Then 1 END 'PHONES'Veera |
|
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2014-04-14 : 08:00:44
|
quote: Originally posted by VeeranjaneyuluAnnapureddy case when d.phone IN (SELECT phone from CALLS where exists(select home_phone, mobile, toll_free from CALLS2)) Then 1 END 'PHONES'Veera
The syntax is correct but it really smells bad. Can we see the whole query? I have a feeling it can be done better. |
|
|
wided
Posting Yak Master
218 Posts |
Posted - 2014-04-17 : 04:18:50
|
case when d.phone IN (SELECT phone from CALLS where exists(select home_phone, mobile, toll_free from CALLS2)) Then 1 ELSE 'PHONES' END |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2014-04-17 : 06:17:27
|
Not one of you bothered to check the query.The exists clause will always be true as long there are rows in Calls2 table since there is no predicate in the query.Also, you have a predicate against Calls table.Is this what you want?CASE WHEN EXISTS (SELECT * FROM dbo.Calls WHERE d.Phone IN (Home_Phone, Mobile, Toll_Free)) THEN 1END AS [Phone] Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA |
|
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2014-04-17 : 08:14:43
|
quote: Originally posted by wided case when d.phone IN (SELECT phone from CALLS where exists(select home_phone, mobile, toll_free from CALLS2)) Then 1 ELSE 'PHONES' END
That's not a complete query. |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
|
|
|
|
|
|