Agile Modeling

 

T-SQL Programming Tips

 

You are here: 

> Home > Development > Databases > SQL Server > Programming

MS SQL Server T-SQL Programming Tips for SQL programmers


Links: 40
Generated on 27.6.2004 at 14:07 GMT

 

 

 

How to Check Data Integrity?


Checking the Integrity of foreign keys a/o all constraints:

DBCC CHECKCONSTRAINTS ('table_name')




Checking the integrity of all enabled / disabled constraints on all tables in current dB:

DBCC CHECKCONSTRAINTS WITH ALL_CONSTRAINTS




Checking the integrity of data, index and other structures:

DBCC CHECKDB
and
DBCC CHECKTABLE ('table_name')




Rebuilding all indices for all tables in the current database:

EXEC sp_MSforeachtable
@command1 = 'DBCC DBREINDEX ("?")'




Defragmentation clustered and secondary indexes of the specified table or view:

DBCC INDEXDEFRAG (database_name, table_name, index_name)




 

 

The Best SQL Tip


Need SQL help?
If you are looking for an SQL programmer or DBA to help you with your SQL project - dB scheme creation, Views, Triggers or SP programming, then you have come to the right place.

See our Services and contact us. We would like to help you!

 

 

 

 

 

 

 

 



 

Do you know?


How to retrieve a list of dependencies for an object in MS SQL:

1. Basic Info

EXEC sp_depends your_object

(It's only showing views and stored procedures for the object.)

2. Added Columns Info

SELECT o1.name 'Procedure',
   c2.name 'Column',
   d.resultobj 'Updated',
   d.readobj 'Read'
 FROM sysdepends d
 JOIN sysobjects o1
   ON d.id = o1.id
 JOIN sysobjects o2
   ON d.depid = o2.id
 JOIN  syscolumns c2
   ON d.depid = c2.id
   AND d.depnumber = c2.colid
 WHERE o2.name = 'your_table'
 ORDER BY o1.name, c2.colid

(Here you can not only see which procedures that references the table, but also which columns they reference.)
 

 

 

 

 

 

 

 

 

 


Previous Page

Top of the Page

Next Page

Art of Programming Network

[Home] [What's new] [Services] [Applications] [Development] [Resources] [About]
 


All Trademarks and Logos belong to their respective owners. We are interested in your Feedback.

Please send your comments to: webmaster[at]artofprogramming[dot]net

Copyright © 2002 - 2007, All rights reserved.