Daily Archives: 24.05.2011

When migrating a database from SQL Server 2000 to SQL Server 2005, it became clear that the line

RAISERROR ('test error %S', 16, 1, @test)

due to wrong written %S instead of %s SQL Server 2000 simply works wrong (returns only the first character of the parameter), but SQL Server 2005 does not create a procedure:
Msg 2787, Level 16, State 1, Line 6
Invalid format specification: ‘%S’.

Because such writing could occur in any procedure, we can find them all::

SELECT name FROM sys.procedures WHERE CHARINDEX ( '%S', OBJECT_DEFINITION(object_id) COLLATE Latin1_General_CS_AS) >0
May 2011
M T W T F S S
« Apr   Jun »
 1
2345678
9101112131415
16171819202122
23242526272829
3031