Link to home
Start Free TrialLog in
Avatar of Camillia
CamilliaFlag for United States of America

asked on

How to know if a string is GUID?

I have a sql statement that joins to 2 tables and brings back an ID row. I changed the design and the new IDs are integers. The old IDs are GUIDs.

How can I know if the ID is GUID and not an integer? based on that, i want to use an if-else statement.

thanks
Avatar of Aeriden
Aeriden
Flag of United States of America image

You can create a SQL Function that would return whether a GUID is valid:

http://ask.sqlservercentral.com/questions/23114/best-way-to-check-that-a-stringvarchar-guid-is-val.html
Avatar of Camillia

ASKER

want to do it in C#, ASP.net. But let me look at your link
SOLUTION
Avatar of Aeriden
Aeriden
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Why not use Guid.Tryparse?
so if (Guid.Tryparse(field) = true)

?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial