Agile Modeling

 

SQL Server DBA Tips

 

You are here: 

> Home > Development > Databases > SQL Server > DBA Tips

MS SQL Server Administration & System Tips for DBA

MS SQL Database Main Page

Links: 58
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)




 

 

SQL Performamce tips - Memory Requirements for SQL server 2000


The memory requirements definitelly depend on your application, database model, SQL procedures, triggers, a/o SQL server setting and optimization. It could be one SELECT command causing the poor performace in your network (e.g. a full table scan or a temp index building for every user).

If you want to see a detailed accounting of how memory is being used in your SQL Server, try this undocumented DBCC command:

DBCC MEMORYSTATUS

(The values refer to the number of 8K buffers.)




Check if your SQL Server has maxed out its memory in the Task Manager - Performance tab:

- "Total" under "Commit Charge (k)" and the "Total" under "Physical Memory (k)"

(If the "Total" under "Commit Charge (k)" is greater than the "Total" under "Physical Memory (k)", then your server does not have enough physical memory to run efficiently.)

- "Available Physical Memory (K)"

(This number should be 4MB or higher. If it is not, then your SQL Server is most likely suffering from a lack of physical RAM, hurting performance, and more RAM has to be added.)




Use Performance Monitor to further investigate the problem.




 

 

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 Run commands for all tables in current dB:

EXEC sp_MSforeachtable
@command1 = 'DELETE FROM ? WHERE your_condition'




How to find Size of all user tables with the number of rows:

EXEC sp_MSforeachtable
@command1='sp_spaceuse d "?"'




How to find Number of rows in a table and the space the table and index use (in KB):

EXEC sp_MStablespace table_name




How to display Size of the datafile and log separately:

EXEC sp_helpdb database_name




How to List of all hard drives and the amount of free space in MB for each drive:

EXEC master..xp_fixeddrives




How to return all tables, which contain a specified column:

SELECT a.name 'Table'
 FROM sysobjects a
  JOIN syscolumns b
  ON a.id = b.id
 WHERE a.type = 'U' AND
  b.name = + 'your_column'




How to Delete a file from the server in SQL:

xp_cmdshell "cmd /c del <filename_with_path>"




How to Control State Options of the Database:

ALTER DATABASE db_name
  SET SINGLE_USER
WITH ROLLBACK AFTER x SECONDS

     or

ALTER DATABASE db_name
  SET RESTRICTED_USER
  (or MULTI_USER)
WITH ROLLBACK IMMEDIATE

(Roll back transactions after the specified number of seconds or immediately.)




 

 

 

 

 

 

 

 

 


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.