When I am executing following ...
EXEC 'DROP TABLE bkp_anish_test'
('DROP TABLE bkp_anish_test'
is a dynamically build sql query)
I am getting following error
Could not find stored procedure 'DROP TABLE bkp_anish_test'.
Do this instead:
exec sp_executesql N'DROP TABLE bkp_anish_test'
or for the case of a dynamically built string:
declare @MyTable nvarchar(100)
set @MyTable = N'bkp_anish_test'
declare @sql nvarchar(100)
set @sql = N'DROP TABLE ' + @MyTable
exec sp_executesql @sql
Try adding parentheses to your command. You must include them when running a SQL statement, if you're going to use the EXEC command.
EXEC ('DROP TABLE bkp_anish_test')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With