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


Please Help Members By Posting Answers For Below Questions

Tell me what is log shipping?

750


Explain iaas, paas and saas?

86


Suppose you want to implement the many-to-many relationships while designing tables. How would you do it?

718


Explain how to send email from sql database?

729


What are various aggregate functions that are available?

691






How to choose all records from the table?

793


what is normalization? Explain different levels of normalization? : Sql server database administration

893


What is the server name in sql server?

714


What are system databases in ms sql server?

699


Explain primary key?

726


What are different backups available in sql server?

757


What were the latest updates to SQL Azure service?

102


Explain tablesample?

727


Explain a checkpoint?

757


Explain the categories of stored procedure?

706