I have a table T, one of the columns is tColumn varchar(8000) After
the table is populated, some field values in tColumn contain GUID
values SELECT * from T In my SELECT I want to filter out all the rows
which have a GUID values (uniqueidentifier) in tColumn. How can I do
it ? Is there function similar to IsNumeric for GUIDs ?...
-Thanks
On 3?2?, ??5?07?, "Sagar" <anandsa
@gmail.com> wrote:
> I have a table T, one of the columns is tColumn varchar(8000) After
> the table is populated, some field values in tColumn contain GUID
> values SELECT * from T In my SELECT I want to filter out all the rows
> which have a GUID values (uniqueidentifier) in tColumn. How can I do
> it ? Is there function similar to IsNumeric for GUIDs ?...
> -Thanks
:)
i suppose this can work.
select patindex('[0-9 A-F][0-9 A-F]-[0-9 A-F][0-9 A-F]-[0-9 A-F][0-9 A-
F]','6F-3A-3D') > 1
-----------------------------------------------Reply-----------------------------------------------
Try something like this:
CREATE TABLE T(X VARCHAR(36) PRIMARY KEY)
INSERT INTO T VALUES ('NOT A GUID')
INSERT INTO T VALUES ('33')
INSERT INTO T VALUES ('2E4F98B9-F95F-4F26-B229-E49E8CE730B2')
INSERT INTO T VALUES ('2E4F98B9-ZZZZ-4F26-B229-E49E8CE730B2')
INSERT INTO T VALUES ('2E4F98B9-33-4F26-B229-E49E8CE730B2')
SELECT X, CASE WHEN X LIKE
REPLICATE('[0-9A-F]',8)+'-'
+REPLICATE(REPLICATE('[0-9A-F]',4)+'-',3)
+REPLICATE('[0-9A-F]',12)
THEN 'YES' ELSE 'NO' END AS IsGUID FROM T
DROP TABLE T
Razvan