Viewing 15 posts - 14,011 through 14,025 (of 15,381 total)
select
TAG_NAME = 'CUST_ALLERGIES',
case CA.MEDICATION_MONIKER
when null then 'No Allergies'
else
CRT.FullName + '~' + M.GENERIC_NAME
end --you have to end your case statement
You really need to use BOL. Here is the article for the...
September 16, 2011 at 2:42 pm
Look at my example of the case statement from several posts ago. A case statement is just a way to conditionally get a value in your query.
select
[other columns],
case [look at...
September 16, 2011 at 2:20 pm
jbalbo (9/16/2011)
So I got the Nolocks and inner joins cleaned up
insert into @TEMPTABLE (TAG_NAME, TAG_DATA)
select TAG_NAME = 'CUST_ALLERGIES',
TAG_DATA =CRT.FullName + '~' + M.GENERIC_NAME
FROM MEDICATION M
left outer JOIN CLIENT_ALLERGY...
September 16, 2011 at 2:02 pm
As Tom and I have pointed out you will have to change your join to a left from an inner. You should read that article I linked about dirty reads....
September 16, 2011 at 1:22 pm
One other point. Why are you using the nolock hint on every table? http://sqlblog.com/blogs/andrew_kelly/archive/2009/04/10/how-dirty-are-your-reads.aspx
September 16, 2011 at 1:10 pm
jbalbo (9/16/2011)
Thanks for the advice..
SO I set it like:
TAG_DATA = isnull(CRT.FullName + '~' + M.GENERIC_NAME)
FROM MEDICATION M WITH (NOLOCK)
INNER JOIN CLIENT_ALLERGY CA ON M.OID = CA.MEDICATION_MONIKER
Inner join CHEMICAL_REFERENCE_TYPE...
September 16, 2011 at 1:08 pm
Well you didn't specify what value to use when it is null.
TAG_DATA = isnull(CRT.FullName + '~' + M.GENERIC_NAME)
Isnull requires two arguments and you only gave it one. Here is the...
September 16, 2011 at 12:46 pm
sqlnaive (9/16/2011)
September 16, 2011 at 12:33 pm
TAG_DATA = isnull(CRT.FullName + '~' + M.GENERIC_NAME, 'No Allergies')
--EDIT--
You might also need to change your join to CLIENT_ALLERGY from an inner join to a left join?
September 16, 2011 at 12:17 pm
Hi and welcome to SSC. The point Cadavre was making is that we don't know your data and there is nobody who is going to translate business rules into your...
September 16, 2011 at 10:15 am
Not to mention how would you do that when there is more than 1 row? Which row of data is the correct row to use as the column name? The...
September 16, 2011 at 8:05 am
The thread itself is not all that interesting but the picture fits 100%.
http://www.sqlservercentral.com/Forums/Topic1171708-338-1.aspx
September 16, 2011 at 7:39 am

Credit to Lowell for the photo.
September 16, 2011 at 7:38 am
Lowell that picture is awesome. It fits perfectly in another thread from a couple days ago. I will have to "steal" your pic and paste it in there.
September 16, 2011 at 7:29 am
hardial_bhatia (9/15/2011)
yeah, have to do it through cursors
WOW!!! The logic in this processing is row by row when all that needs to happen is two single update statements. If you...
September 15, 2011 at 3:01 pm
Viewing 15 posts - 14,011 through 14,025 (of 15,381 total)