-
Dear All,
I would like to execute a DDL statement(create table) in an SQL server stored procedure. I am formulating the DDL statement in the stored procedure and is saved in a variable of type varchar. How do I execute that DDL statement.
Thanks in advance
-
...
Just a quick example
...
create proc sp_AdhWmCreateRXCRTables with recompile as
begin
declare @command varchar(60)
declare @usename varchar(60)
set nocount on
select @usename = "tblmsdnexpert"
if OBJECT_ID(@usename) is not null
begin
select @command = 'DROP TABLE ' + @usename
exec (@command)
end
select @command = 'CREATE TABLE(......etc"
exec (@command) should do it...
I hope I understood your question correctly..