Search code examples
sql-servert-sqlsql-server-2000

Format SQL Server Field


I need a way to remove a comma if that is the 1st character in a field. For example, the data would be ,Monday instead of reading just Monday How can I 1st check if the comma is the 1st character in a field, and if it is remove it?


Solution

  • SELECT CASE
             WHEN YourCol LIKE ',%' THEN SUBSTRING(YourCol, 2, 8000)
             ELSE YourCol
           END