Reseeding (reseting) the identity of a table is really simple in SQL Server.
Check it out:
DBCC CHECKIDENT (TableName, reseed, 0)
This will reset the identity to 0 and any row inserted from this point on will start with 1. You can set the third parameter to any integer value.
Monday, June 17, 2013
Thursday, June 13, 2013
Time span intersection check in SQL Server.
While working in SQL server, a co-worker and I were trying to figure out how to tell if two time spans intersect in any way. We thought that the best way to do this would be to check for the opposite since there would be alot less check in those instances. Check it out!
if (@Beg1D <= @End1D and @Beg2D <= @End2D)
if (@Beg2D > @End1D or @Beg1D > @End2D)
Set @TimeSpansDoIntersect = 0
else
Set @TimeSpansDoIntersect = 1
else
Set @TimeSpansDoIntersect = null
if (@Beg1D <= @End1D and @Beg2D <= @End2D)
if (@Beg2D > @End1D or @Beg1D > @End2D)
Set @TimeSpansDoIntersect = 0
else
Set @TimeSpansDoIntersect = 1
else
Set @TimeSpansDoIntersect = null
Subscribe to:
Posts (Atom)