Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 HELP - Newbie!

Author  Topic 

LerrynDT
Starting Member

3 Posts

Posted - 2008-10-17 : 09:15:55
Hi

I am totally new to SQL, please can you tell me what the following script would be used for on any SQL tables -

_____________________________________________________
USE MMSv3_DemoData

DECLARE @TableName varchar(255)

DECLARE TableCursor CURSOR FOR
SELECT table_name FROM information_schema.tables
WHERE table_type = 'base table'

OPEN TableCursor

FETCH NEXT FROM TableCursor INTO @TableName
WHILE @@FETCH_STATUS = 0
BEGIN
DBCC DBREINDEX(@TableName,' ',90)
FETCH NEXT FROM TableCursor INTO @TableName
END

CLOSE TableCursor

DEALLOCATE TableCursor
________________________________________________________

Thanks in Advance

The Newbie!

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2008-10-17 : 09:23:59
IT will rebuild the indexes on all of the tables in your database.

look up DBCC DBREINDEX in books on line.

DBREINDEX is an offline job but typically it won't take long (depending on your table sizes of course)

Make sure you don't run this on a live server unless you know exactly what it's going to do.

NB: Changed "Look up DBREINDEX" to "Look up DBCC DBREINDEX" as the former wont find much!
-------------
Charlie
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2008-10-17 : 09:27:02
And DBCC DBREINDEX will be depreciated in future versions of SQL Server. Functionality will be subsumed into the ALTER INDEX statement.

-------------
Charlie
Go to Top of Page

LerrynDT
Starting Member

3 Posts

Posted - 2008-10-17 : 09:29:23
Thanks Charlie, makes a bit more sense to me now.
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2008-10-17 : 09:32:21
Is it indexes or indices?

-------------
Charlie
Go to Top of Page

LerrynDT
Starting Member

3 Posts

Posted - 2008-10-17 : 09:49:19
Isn't it Indices????
Go to Top of Page

tosscrosby
Aged Yak Warrior

676 Posts

Posted - 2008-10-17 : 09:54:22
Word's spellcheck accepts either one. I always use "indexes" but either would be acceptable in conversation. Besides, who are we trying to impress?? DBAs have there own language anyway!

Terry
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-17 : 10:02:01
quote:
Originally posted by tosscrosby

Word's spellcheck accepts either one. I always use "indexes" but either would be acceptable in conversation. Besides, who are we trying to impress?? DBAs have there own language anyway!

Terry


I've always used indexes rather than indices.
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2008-10-17 : 11:17:43
quote:
Originally posted by visakh16

quote:
Originally posted by tosscrosby

Word's spellcheck accepts either one. I always use "indexes" but either would be acceptable in conversation. Besides, who are we trying to impress?? DBAs have there own language anyway!

Terry


I've always used indexes rather than indices.



That's better than me. I usually end up referring to them as 'thingies' or 'whatdoyacallems'

-------------
Charlie
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-17 : 11:18:51
quote:
Originally posted by Transact Charlie

quote:
Originally posted by visakh16

quote:
Originally posted by tosscrosby

Word's spellcheck accepts either one. I always use "indexes" but either would be acceptable in conversation. Besides, who are we trying to impress?? DBAs have there own language anyway!

Terry


I've always used indexes rather than indices.



That's better than me. I usually end up referring to them as 'thingies' or 'whatdoyacallems'

-------------
Charlie


Personalised jargons?
Go to Top of Page
   

- Advertisement -