Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 1234»»»

'DBCC' is not recognized as an internal or external command Expand / Collapse
Author
Message
Posted Monday, October 15, 2012 3:25 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, October 22, 2012 1:11 PM
Points: 15, Visits: 34
Hi,

Can anyone tell me what am i missing if i tried to test my script on the command prompt and gives me this error

'DBCC' is not recognized as an internal or external command.

Below is my script

DBCC Shrinkfile('ABC_CAS_log',EMPTYFILE )
DBCC Shrinkfile('ABCLogging_log',EMPTYFILE )

any help is greatly appreciated

thanks,

aguzman
Post #1372965
Posted Monday, October 15, 2012 3:44 PM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Today @ 5:32 PM
Points: 901, Visits: 7,161
How are you executing this? DBCC is a command that SQL Server recognizes but the OS does not. You need to execute the DBCCs like you would execute any other SQL, through a connection to the server.



And then again, I might be wrong ...
David Webb
Post #1372975
Posted Tuesday, October 16, 2012 8:16 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, October 22, 2012 1:11 PM
Points: 15, Visits: 34

i am a sql newbie. i will appreciate if you can provide more details in your reply.

thanks david.
Post #1373297
Posted Tuesday, October 16, 2012 8:26 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 2:51 PM
Points: 42,756, Visits: 35,850
You execute DBCC commands exactly as you execute any database query (select, update, insert, delete, etc). The error suggests you're trying to run them from the OS command prompt, that won't work, they're SQL commands, not OS commands


Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1373308
Posted Tuesday, October 16, 2012 9:07 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, October 22, 2012 1:11 PM
Points: 15, Visits: 34
Thanks Gail,

again sorry for the ignorance. HOw should my script execute that query? Given the script.. how should my make it run in DOS command as we need this script to run in DOS command for test before we can place it to BackupAssist software.


DBCC Shrinkfile('CCGA_CAS_log',EMPTYFILE )
DBCC Shrinkfile('Logging_log',EMPTYFILE )

please give us a hint.

I appreciate your comment.
Post #1373342
Posted Tuesday, October 16, 2012 9:15 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Today @ 5:32 PM
Points: 901, Visits: 7,161
Look up SQLCMD, a utility that can run as a DOS command and read your script as input, connect to the SQL Server and execute your script.

Here's a link:
http://msdn.microsoft.com/en-us/library/ms162773.aspx




And then again, I might be wrong ...
David Webb
Post #1373348
Posted Tuesday, October 16, 2012 9:59 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, October 22, 2012 1:11 PM
Points: 15, Visits: 34
Hi David,

thanks for the feedback.

i do have a question for you, you said that I need to execute the DBCC command like i am executing sql through a connection to the server,

can you give me an example on how i can achieved this?

again thank you..
Post #1373375
Posted Tuesday, October 16, 2012 10:03 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 2:51 PM
Points: 42,756, Visits: 35,850
Look up SQLCMD. It's a command-line (runs from OS command console) SQL Server querying tool (runs commands against whatever SQL Server it connects to)


Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1373379
Posted Tuesday, October 16, 2012 10:10 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, October 22, 2012 1:11 PM
Points: 15, Visits: 34
I have tried the link you provided earlier and installed the package but can get the sqlcmd running.

anyway thanks for your help.
Post #1373383
Posted Tuesday, October 16, 2012 10:15 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Today @ 5:32 PM
Points: 901, Visits: 7,161
SQL Server is a service that runs like any other service under the OS. In order to issue commands or SQL statements to the server, you have to connect to the server and send those commands or statements to the server to execute them on your behalf. You can get a connection to the running SQL Server service in several ways. You can connect with SQL Server Management Studio, a graphical user interface for administration and development. You can use several command line utilities, like OSQL or SQLCMD that can be executed as OS level commands but which can take in script files with SQL statements and execute then in 'batch' mode. So in your case (based on what I've seen so far), you'd create a text file with the DBCC commands in it (let's call it dbcc.sql) and then issue something like the following at the OS command prompt (or in a batch file):

SQLCMD -Sservername -Uuserid -Ppassword -idbcc.sql -ooutput.txt

This is basic syntax and there are several options ( you might use -E and remove the -U and -P if you are using windows authentication) that you need to choose. The above syntax will read in the dbcc.sql and execute those at the server and write out the results to the output.txt file for later examination.




And then again, I might be wrong ...
David Webb
Post #1373388
« Prev Topic | Next Topic »

Add to briefcase 1234»»»

Permissions Expand / Collapse