Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


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


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

Author
Message
guzman_anthony
guzman_anthony
Grasshopper
Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)

Group: General Forum Members
Points: 17 Visits: 35
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
David Webb-CDS
David Webb-CDS
Ten Centuries
Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)

Group: General Forum Members
Points: 1028 Visits: 8584
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
guzman_anthony
guzman_anthony
Grasshopper
Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)

Group: General Forum Members
Points: 17 Visits: 35
i am a sql newbie. i will appreciate if you can provide more details in your reply.

thanks david.
GilaMonster
GilaMonster
SSC Guru
SSC Guru (54K reputation)SSC Guru (54K reputation)SSC Guru (54K reputation)SSC Guru (54K reputation)SSC Guru (54K reputation)SSC Guru (54K reputation)SSC Guru (54K reputation)SSC Guru (54K reputation)

Group: General Forum Members
Points: 54446 Visits: 44648
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, MVP, M.Sc (Comp Sci)
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


guzman_anthony
guzman_anthony
Grasshopper
Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)

Group: General Forum Members
Points: 17 Visits: 35
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.
David Webb-CDS
David Webb-CDS
Ten Centuries
Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)

Group: General Forum Members
Points: 1028 Visits: 8584
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
guzman_anthony
guzman_anthony
Grasshopper
Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)

Group: General Forum Members
Points: 17 Visits: 35
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..
GilaMonster
GilaMonster
SSC Guru
SSC Guru (54K reputation)SSC Guru (54K reputation)SSC Guru (54K reputation)SSC Guru (54K reputation)SSC Guru (54K reputation)SSC Guru (54K reputation)SSC Guru (54K reputation)SSC Guru (54K reputation)

Group: General Forum Members
Points: 54446 Visits: 44648
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, MVP, M.Sc (Comp Sci)
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


guzman_anthony
guzman_anthony
Grasshopper
Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)

Group: General Forum Members
Points: 17 Visits: 35
I have tried the link you provided earlier and installed the package but can get the sqlcmd running.

anyway thanks for your help.
David Webb-CDS
David Webb-CDS
Ten Centuries
Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)

Group: General Forum Members
Points: 1028 Visits: 8584
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
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search