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 |
Analyzer
Posting Yak Master
115 Posts |
Posted - 2014-03-11 : 10:46:29
|
Hi. Wish to convert an INT value from the registry to a VARCHAR but not sure how to convert from INT to VARCHAR within a CASE statement. Below is my code which current fails on "Conversion failed when converting the varchar value 'Automatic' to data type int". Any ideas please?DECLARE Var1 INTEXECUTE master.dbo.xp_instance_regread @rootkey = N'HKEY_LOCAL_MACHINE', @key = N'SYSTEM\CurrentControlSet\Services\SQLServerAgent', @value_name = N'Start', @value = @Var1 OUTPUTselect case WHEN @Var1 =4 THEN 'Disabled' WHEN @Var1 =3 THEN 'Manual' WHEN @Var1 =2 THEN 'Automatic' ELSE 0 END FROM sys.dm_os_sys_info select @Var1 |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2014-03-11 : 10:57:45
|
try ELSE '0' instead of ELSE 0 Too old to Rock'n'Roll too young to die. |
 |
|
Analyzer
Posting Yak Master
115 Posts |
Posted - 2014-03-11 : 11:22:59
|
Boom. That worked great. Thanks you |
 |
|
|
|
|