|
|
|
Grasshopper
      
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
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Today @ 4:25 PM
Points: 825,
Visits: 5,690
|
|
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
|
|
|
|
|
Grasshopper
      
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.
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Today @ 3:07 PM
Points: 37,687,
Visits: 29,946
|
|
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
|
|
|
|
|
Grasshopper
      
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.
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Today @ 4:25 PM
Points: 825,
Visits: 5,690
|
|
|
|
|
|
Grasshopper
      
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..
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Today @ 3:07 PM
Points: 37,687,
Visits: 29,946
|
|
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
|
|
|
|
|
Grasshopper
      
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.
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Today @ 4:25 PM
Points: 825,
Visits: 5,690
|
|
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
|
|
|
|