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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 DBCC command in a cursor

Author  Topic 

pareshmotiwala
Constraint Violating Yak Guru

323 Posts

Posted - 2008-01-02 : 16:55:29
can i use a dbcc command in a cursor.

I am currently trying to run dbcc help command for all the dbcc command available by using:

DECLARE dbcc_commands insensitive CURSOR
READ_ONLY
FOR
dbcc help ('?')
--FOR READ_ONLY

DECLARE @name varchar(1024)
OPEN dbcc_commands

where am I screwing up?


Regards
Paresh Motiwala
Boston, USA

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-01-02 : 16:56:37
Where is your select statement that defines what records to cursor over? Have you looked at the cursor examples in BOL?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

pareshmotiwala
Constraint Violating Yak Guru

323 Posts

Posted - 2008-01-02 : 17:12:35
Hi Tara
happy new year.
dbcc help('?') returns names of dbcc commands.
I just want to be able to run dbcc help for each of these values returned.
Thanks

Regards
Paresh Motiwala
Boston, USA
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-01-02 : 17:17:34
Put the commands into a temp table. Then use a loop to go through each database and run each command from the temp table. So you'll end up with two loops.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

pareshmotiwala
Constraint Violating Yak Guru

323 Posts

Posted - 2008-01-03 : 09:30:57
okie dokie. Just read it, had to leave yesterday to catch a train.

Regards
Paresh Motiwala
Boston, USA
Go to Top of Page
   

- Advertisement -