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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Local Variable

Author  Topic 

ben_53
Yak Posting Veteran

67 Posts

Posted - 2011-09-06 : 16:37:32
Hi All,

I have my_table with 2 columns.
col1 = ID
col2 = Error.

Now, I have a business logic where I can get multiple error messages in col2. but I am able to get only one error message (last updated).
for example :
logic1 can produce error1
logic2 can produce error2 and so on..

but in my col2, I am able to get the lastupdated message only.
whereas I want 'error1' + 'error2'+... (where applicable)

please help me defining a variable for error message and add other error messages in the same (if applicable)

Lets simplify this.
Lets say I already have 'some data' in col2 but my new logic1 can produce a data that needs to be added in col2.
example
(originally)
id error
122 <data expired>

applying business logic1 it also produces the message <data corrupted>

Expected result
id error
122 <data expired> + <data corrupted>


Thanks

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-09-06 : 22:33:13
make an update like

update yourtable
set error = error + @newerror
where id = @someid

where @newerror contains latest error received for @id

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -