I want to run the following but I get an error at the '-' in front of 'U'
sqlcmd -U foo -P Bar -S server -D db -Q "use db truncate table Table1"
Thanks for the help
EDIT:
TRUNCATE TABLE table1
Does not work as it says I do not have permission.
I want to run the following but I get an error at the '-' in front of 'U'
sqlcmd -U foo -P Bar -S server -D db -Q "use db truncate table Table1"
Thanks for the help
EDIT:
TRUNCATE TABLE table1
Does not work as it says I do not have permission.
Specified the location of my table with
TRUNCATE TABLE server.db.table1
Your syntax is correct - except that -D
should be -d
- but you didn't post the exact error so it isn't entirely clear what's wrong. However, I think you might be executing your sqlcmd command in Management Studio; doing that gives me this error:
Msg 102, Level 15, State 1, Line 1 Incorrect syntax near 'U'.
But sqlcmd.exe is a command-line tool, so you should execute it from a command prompt, not from SSMS (please note that SQLCMD mode in SSMS is not the same thing as running sqlcmd.exe from the command line).