Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
I'm trying to do something like this: MERGE master.dbo.sysmessages SM USING (SELECT SystemID, DisplayMessage FROM ErrorMessages) NR ON SM.error = NR.SystemID WHEN NOT MATCHED THEN BEGIN EXEC sp_addmessage @msgnum = NR.SystemID,@severity = 16,@msgtext = NR.DisplayMessage END;Isn't it possible without cursor?thanks
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2011-11-21 : 04:50:46
i think you cant use MERGE like this. you need call sp in a loop and insert each new error message in it------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
MikeSamteladze
Starting Member
2 Posts
Posted - 2011-11-21 : 05:02:51
This is the only solution for me now, but I'll keep search the way without loop.Thanks
johntech
Yak Posting Veteran
51 Posts
Posted - 2011-11-24 : 09:44:22
I'm not sure ,but I thought that below code may be useful
MERGE master.dbo.sysmessages SMif (SELECT SystemID, DisplayMessage FROM ErrorMessages) NR ON SM.error != NR.SystemID THENBEGINEXEC sp_addmessage @msgnum = NR.SystemID,@severity = 16,@msgtext = NR.DisplayMessageEND;