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 are three major types of constraints?
Explain user defined views?
List out different types of normalizations in sql server and explain each of them?
What do you understand by intent locks?
What is a non-clustered index?
Create and insert into temp table in sql server?
Can a stored procedure call itself or recursive stored procedure? How much level sp nesting is possible?
What are system databases into sql server (2005/2008) : sql server database administration
How to create a simple user defined function in ms sql server?
What are parameterized reports? What are cascading parameters in ssrs reports?
What do you know about normalization and de- normalization?
In what sequence sql statement is processed?
Your table has a large character field there are queries that use this field in their search clause what should you do?
What are the results of running this script?
Tell me about joins in database system and explain each in detail.