Friday, August 26, 2011

sql server database how to drop database forcefully

There are many ways to drop database forcefully
1) we need to find active process spid and we need kill
2) following query will help to drop database forcefully


IF EXISTS(SELECT 1 FROM sysdatabases WHERE [NAME]='databaseName')

BEGIN

ALTER DATABASE databaseName

SET SINGLE_USER

WITH ROLLBACK IMMEDIATE;

ALTER DATABASE databaseName

SET MULTI_USER

WITH ROLLBACK IMMEDIATE;

DROP DATABASE databaseName



END

happy coding...

Tuesday, August 23, 2011

sql server how to reset identity column

Following query can help for resting identity column

Query
------
DBCC CHECKIDENT('tableName', RESEED, 0)

happy coding.....