Showing posts with label sql. Show all posts
Showing posts with label sql. Show all posts

Saturday, November 7, 2009

SQL datetime headaches

I'm always hassleing with datetimes in the SQL Server database to get the correct datetime format that i want. It seems that most of this stuff you can do with specifying a format when converting it:
Usefull page for that

But it did not realy have what i wanted from it.

So the final solution was the following
to get a format like this:
2008-11-13 17:29:00

I needed to do the following

SET generated = cast( getdate() - 8 as smalldatetime)

Friday, September 11, 2009

Reset auto number from a SQL table after delete

When you have an auto number on a table and you deletes the rows in the table you have to reset the autonumber value.


DELETE FROM tblName
DBCC CHECKIDENT (tblName,RESEED, 0)

The first lines throws all the rows in tblName away and with the second row the auto number is reset


read here more information

Monday, August 24, 2009