How to check if a string is a uniqueidentifier?

前端 未结 12 905
小蘑菇
小蘑菇 2020-11-29 03:06

Is there an equivalent to IsDate or IsNumeric for uniqueidentifier (SQL Server)? Or is there anything equivalent to (C#) TryParse?

Otherwise I\'ll have to write my o

12条回答
  •  离开以前
    2020-11-29 03:40

    I had some Test users that were generated with AutoFixture, which uses GUIDs by default for generated fields. My FirstName fields for the users that I need to delete are GUIDs or uniqueidentifiers. That's how I ended up here.

    I was able to cobble together some of your answers into this.

    SELECT UserId FROM [Membership].[UserInfo] Where TRY_CONVERT(uniqueidentifier, FirstName) is not null

提交回复
热议问题