November 21, 2016

Ms SQL Useful Stored Procedures

DBCC CHECKDB ('DB_Name')
DBCC CHECKALLOC ('DB_Name')
DBCC updateusage ('DB_Name')
DBCC CHECKIDENT ('dbo.tablename',reseed,0
- '0' by default,Seed Value Last Incremented value can be added

EXEC SP_help

EXEC SP_helptext

EXEC sp_renamedb 'oldname' , 'newname';

xp_fixeddrives  - To get HD available in the Server / Disk Space

To assign a db owner for the orphan databases, execute the below command for the individual databases.

To Find Orphan DB's,
SELECT name, SUSER_SNAME(sid) FROM master.dbo.sysdatabases
WHERE SUSER_SNAME(sid) IS NULL


sp_changedbowner 'sa'


SQL SERVER – Maximum Number of Index per Table
For SQL Server 2005:
1 Clustered Index + 249 Non-clustered Index = 250 Index
For SQL Server 2008 and Above
1 Clustered Index + 999 Non-clustered Index = 1000 Index

No comments:

Post a Comment