A simple function that checks if a passed string is a GUID.
create function IsGuid ( @testString varchar(38))
returns int
as
begin
declare @ret int
select @ret = 0,
@testString = replace(replace(@testString, '{', ''), '}', '')
if len(isnull(@testString, '')) = 36 and
@testString NOT LIKE '%[^0-9A-Fa-f-]%' and
-- check for proper positions of hyphens (-)
charindex('-', @testString) = 9 and
...
this is a select trigger on a table. found this in a blog of our first Slovenian Sql Server MVP (i think he's first :))).
http://solidqualitylearning.com/blogs/dejan/archive/2004/11/25/214.aspx
quite interesting...
This is a list of some stuff (mostly beginner) i've learned here on SQLTeam forums and i've written them down over time... i've posted it in forums here and Madhivanan gave the idea to blog it... so i did. :)) maybe this will help in the planned beginners forum :))
1. How to update a column with incrementing numbers:
-- whole table (identity stlye)
declare @table1 table (id int, name varchar(50))
insert into @table1
select null, 'text1' union all
select null, 'text2' union all
...