SQL conversion from varchar to uniqueidentifier fails in view

前端 未结 1 1812
孤独总比滥情好
孤独总比滥情好 2020-12-07 02:45

I\'m stuck on the following scenario. I have a database with a table with customer data and a table where I put records for monitoring what is happening on our B2B site.

1条回答
  •  余生分开走
    2020-12-07 03:08

    Use

    TRY_CONVERT(UNIQUEIDENTIFIER, parameter2) AS customerguid
    

    instead of

     CONVERT(UNIQUEIDENTIFIER, parameter2) AS customerguid
    

    Views are inlined into the query and the CONVERT can run before the WHERE.

    For some additional discussion see SQL Server should not raise illogical errors

    0 讨论(0)
提交回复
热议问题