Sunday, September 21, 2014

Truncating a Table from MSSQL Server

I was having a problem truncating a table in MSSQLServer 2008.

Kept getting an error similar to this one:
Cannot find the object because it does not exist or you do not have permissions , error in SQL Server

The following code worked for me:

Exec [PutDatabaseNameHereAndRemoveBrackets].sys.sp_executesql N'TRUNCATE TABLE dbo.[PutTableNameHereAndRemoveBrackets]'