Hi all,
I have question (surprise!). I am trying to populate a local variable with concatenated strings based on a comparison. Logically what I want to do is something like
if table1.field1 is like 'x' THEN (@localVar = 'yyy '),
if table1.field2 is like 'x' THEN (@localVar = (@localVar + 'yyy ')),
The best effort I could make was something like:
SELECT
@notesString =
(CASE WHEN tblExtra.Extraheader='4wd' THEN (@notesString ='4WD ')END)
(CASE WHEN tblExtra.Extraheader='Aachk' THEN (@notesString = (@notesString + 'aa '))END)
,
...
And I'm getting this error:
Server: Msg 141, Level 15, State 1, Procedure casey_qryCROSSTAB_emulator_30-10-2003, Line 7
A SELECT statement that assigns a value to a variable must not be combined with data-retrieval operations.
I'm very new to T-SQL and not familiar with its limitations, any help offered would be gratefully recieved!
Thanks in advance for your valuable time!
KC.
I have question (surprise!). I am trying to populate a local variable with concatenated strings based on a comparison. Logically what I want to do is something like
if table1.field1 is like 'x' THEN (@localVar = 'yyy '),
if table1.field2 is like 'x' THEN (@localVar = (@localVar + 'yyy ')),
The best effort I could make was something like:
SELECT
@notesString =
(CASE WHEN tblExtra.Extraheader='4wd' THEN (@notesString ='4WD ')END)
(CASE WHEN tblExtra.Extraheader='Aachk' THEN (@notesString = (@notesString + 'aa '))END)
,
...
And I'm getting this error:
Server: Msg 141, Level 15, State 1, Procedure casey_qryCROSSTAB_emulator_30-10-2003, Line 7
A SELECT statement that assigns a value to a variable must not be combined with data-retrieval operations.
I'm very new to T-SQL and not familiar with its limitations, any help offered would be gratefully recieved!
Thanks in advance for your valuable time!
KC.