Posts Tagged ‘Sql Server’

ISNULL() and COALESCE()

  Original Post here In dealing with NULL values in SQL Server, the developer is often faced with the requirement to evaluate the content of a field, and when said field in null, return another value (or field). There are two functions in SQL Server which support this requirement: ISNULL() and COALESCE.() ISNULL COALESCE ISNULL [...]

More »

T-SQL, Left padding ’0′

Following example will pad ’0′ to left of a string ’16′ to ’016′. RIGHT(’000′ + RTRIM(DEPARTMENTNUMBER), 3) UPDATE DEPARTMENT SET DEPARTMENTNUMBER = RIGHT(’000′ + RTRIM(DEPARTMENTNUMBER), 3), OFFICEDEPARTMENT = OFFICENUMBER + ‘-’ + RIGHT(’000′ + RTRIM(DEPARTMENTNUMBER), 3)

More »