A quick expression to change an INT like 1234567 to a comma-separated NVARCHAR like '1,234,567'.
REPLACE(CONVERT(NVARCHAR, CONVERT(MONEY, CountPages), 1), '.00', '')
sounding - noun. 1. the act of taking a measure of depth
2. a probe of an environment
A quick expression to change an INT like 1234567 to a comma-separated NVARCHAR like '1,234,567'.
REPLACE(CONVERT(NVARCHAR, CONVERT(MONEY, CountPages), 1), '.00', '')
Here's a small script to rebuild all the indexes on all the tables in a given database:
EXEC sp_MsForEachTable 'USE [YourDatabase] PRINT ''?'' DBCC DBREINDEX (''?'', '' '', 70)'
Be sure to read Books OnLine about "DBCC DBREINDEX" - it's probably not something you want to do during peak hours.
Here's a quick way to get the row counts for every table in a given database:
DBCC UPDATEUSAGE(YourDatabase)
SELECT so.name AS 'Table Name',
si.rows AS 'Row Count'
FROM sysobjects so
JOIN sysindexes si
ON so.id = si.id
WHERE so.type = 'U'
AND si.indid IN (0, 1)
ORDER BY si.rows DESC
This is quick because it looks in the system tables instead of at the tables themselves. (If you include the DBCC UPDATEUSAGE statement, it will take a while, but is sure to be accurate.)
It just doesn't get any better than this:
Jeff's SQL Server Blog: "The Joy of Blog Feedback"
|
|
Larry Leonard |
| Larry@LarryLeonard.net | |
| Lawrenceville, Georgia, United States | |
| United States | |
| Before making the move to SQL Server, Larry specialized in Windows programming in C/Win32, C++/MFC, and C#/.NET. His blog focuses on query tuning, database optimization, and system performance, and features handy scripts, practical tips, and occasional dispatches from the many dark corners of SQL Server. | |