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.
Author |
Topic |
denis_the_thief
Aged Yak Warrior
596 Posts |
Posted - 2013-05-27 : 13:18:03
|
We are looking into Raising Language-specific errors.I noticed that SQL Server supports multiple languages for the same message id such as:EXEC sp_addmessage 120063, 16, 'test message.', @lang = 'US_English';EXEC sp_addmessage 120063, 16, 'test message Norwegian.', @lang = 'Norwegian';But we want to raise error message 120063 for a language based on some criteria. I know that you can say:SET LANGUAGE Norwegian; GO But we want to do this based on some setting that can specify the language. I wish you could specify a language with RAISEERROR but looks like I can't. Any ideas how we can get around this? |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-05-27 : 20:41:03
|
I don't know of a direct way to achieve what you are trying to do. The only thing I can think of is to query master.dbo.sysmessages with the messageid and the variable that representing the language to get the message string, and then present it. For example:declare @msgstring varchar(255);select @msgstring = [description] from sysmessageswhere 120063 = 5001 and msglangid = 1044raiserror(@msgstring,16,1); If you have parameter tokens in the message, then you will need to do more work to do C-like substitution of positional parameters. |
|
|
|
|
|