You could use the following solution:
SELECT tiMNMmbrno,
ttMNMnincr,
tvMNMntype,
tvMNMrelat,
tvMMBclass,
tsMMBmyear,
tvMMBmpref,
tcMNMfirst,
tcMNMmidle,
tcMNMlastn,
tvMNMgnrtn,
tcMADline1...
This should do what youre looking for:
DECLARE @a TABLE ( col1 VARCHAR(25) )
INSERT @a ( col1 )
SELECT NULL UNION
SELECT 'GL' UNION
SELECT 'GL/PRIMARY' UNION
SELECT 'GL/PRIMARY/OCCURANCE'
SELECT col1,
CASE WHEN CHARINDEX('/', col1) = 0 THEN col1...
Yes, you are correct. It is dependent on a static set of values in the source column otherwise it will fail. I keep thinking there must be a more elegant way to provide the data that doesnt involve looping or throwing my suggestion into a dynamic script (which at that point would be even more...
forgot to post the result set:
PRODUCTID PRICEDATE BASE_PRICE A_PRICE_INCREASE B_PRICE_INCREASE C_PRICE_INCREASE D_PRICE_INCREASE
----------- -----------------------...
I thought there had to be an easier way. I just didn't think it would kill me..."
Qik3Coder,
It really seems like it should be easier but, as my code attests to, I didnt find that easy solution.
I do see where I have a problem displaying multiple different prices for a product in my code...
Sorry for the late reply...
If you have a static number of sources the following (untested) code should work:
DECLARE @a TABLE(
PRODUCTID INT,
PRICEDATE DATETIME,
PRICE DECIMAL(8,2),
SOURCE CHAR(1) )
INSERT @a ( PRODUCTID, PRICEDATE, PRICE, SOURCE )
SELECT 1, '20080102', 10.12, 'A' UNION...
There is no need to loop anything.
update <your table>
set <column1> = ltrim(rtrim(<column1>)),
<column2> = ltrim(rtrim(<column2>)),
...
<column68> = ltrim(rtrim(<column68>))
However, I would think you would better off validating the data when created rather than scrubbing it after...
Running your [400.PatientAge] in your derived table through a case statement similar to this would pass a numeric value to your case statement in your select statement:
declare @a table ( age varchar(10) )
insert @a ( age )
select '1 yr' union all
select '3 mo' union all
select '10 wks'
select...
Since you are doing numeric comparisons in your case statement against [400.PatientAge] I would assume that you have non-numeric values stored in that column.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.