i want to create procedure for create table in sql server
2005
for example
create procedure create_table
@table varchar(20)
as
create @table(
id int,
name char(20)
)
but it will get error
what is solution?
Answer Posted / saravanan sankar
CREATE PROCEDURE create_table
@table varchar(20)
AS
BEGIN
declare @string varchar(5000)
set @string = 'CREATE TABLE '+ @table +'(id int,name char(20))'
END
exec(@string)
//FIRST RUN PROCEDURE ABOVE AND THEN EXECUTES
EXEC create_table 'TABLE1'
| Is This Answer Correct ? | 8 Yes | 1 No |
Post New Answer View All Answers
What is the function of sql server agent windows service?
Define outer join in sql server joins?
If you want to send some data from access database to sql server database. What are different component of ssis will you use?
What do you mean by collation recursive stored procedure?
What is difference between equi join and inner join?
Why it is recommended to avoid referencing a floating point column in the where clause?
What are the characteristics of modern DBMS?
What's new in sql management studio for sql server? : sql server management studio
Explain partitioned view?
What is sql server agent and what are the two modes of authentication in sql server?
What is xml datatype?
How to provide column names in insert statements in ms sql server?
How can you append an identity column to a temporary table?
what is the different types of backups available in sql server? : Sql server database administration
Why and when do stored procedure recompile?