Get Specific Info From SQL Error Message 547

How do I correctly extract specific info from an sql error message number 547?

Info Required:

  • What is the advantage of using a date dimension table over directly storing a date?
  • How can I create two commands in one connection?
  • Join two table using sql query
  • SQL DateTime Format Convert
  • SSIS Conditional Split NULL handling
  • SQL Server : showing Empty Row Select TOP 5
    • Table Name
    • Constraint Name
    • Column Name

    Code:

    Try 
      ....
    Catch ex As System.Data.SqlClient.SqlException 
            If ex.Number = 547 Then
    
            End If
    End Try
    

    Sample message:

    UPDATE statement conflicted with COLUMN CHECK constraint
    ‘CK_Birthdate’. The conflict occurred in database ‘Northwind’, table
    ‘Employees’, column ‘BirthDate’.

  • Encryption SQL Server 2005
  • Cannot bulk load. Operating system error code 5 (Access is denied.)
  • Azure SQL maintenance
  • Financial data group by date, even if data is null
  • SQL Server multiple Exists where every exists has a NULL condition of main table
  • SQL query to look for a Kevin Bacon number of 2
  • 2 Solutions collect form web for “Get Specific Info From SQL Error Message 547”

    There is no straight forward way of getting these pieces of information separately.

    It all gets concatenated into the error message.

    You can use select * from sys.messages where message_id=547 to see the various different language formats of the message that you would need to deal with in order to extract the constituent parts then perhaps use regular expressions with capturing groups based around this information.

    In addition to queries, here’s a powershell script which wraps the sys.messages queries.

    http://blogs.msdn.com/b/buckwoody/archive/2009/04/30/and-the-winner-is-get-sql-server-error-messages-from-powershell.aspx

    MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.