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
Give the query of getting last two records from the table in SQL SERVER?
How to send email from database?
Write an sql query to find first weekday of the month?
Beginning with sql server version 7 0, a new enhanced data type nchar was added what type of data is supported with this data type?
What is sql server replication? : sql server replication
how you can get the list of largest tables in a database? : Sql server administration
What is the use of @@spid?
Tell me what is difference between view and materialized view?
How will you optimize a stored procedure optimization?
What are the different editions available in sql server 2000?
What is rolap and its advantage? : sql server analysis services, ssas
What is the minimum and maximum number of partitions required for a measure group? : sql server analysis services, ssas
Explain full-text query in sql server?
Using the customer, and order table in northwind database, please write a query to produce xml?
Is it safe to delete log files?