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 / patan
IF EXISTS (SELECT NAME FROM SYSOBJECTS WHERE NAME = 'PROCEDURENAME')
DROP PROCEDURE PROCEDURENAME
GO
CREATE PROCEDURE PROCEDURENAME
@TEST INT = 0
AS
BEGIN
--HERE CREATING TABLE
DECLARE @CREATE TABLE (ID INT ,NAME VARCHAR(20))
INSERT INTO @CREATE VALUES (1,'PATAN')
.
.
.
.
.
.
END
IN PROCEDURE WE CAN CREATE TABLE AND IT CAN USE THE OUR PROCEDURE @CREATE IS THE TABLE NAME
NOTE:WHILE RUNNING TIME WE CAN CREATE TABLE WITH THERE ALIES NAMES...
THANKS @ GOOD LUCK
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
If you lose rights to your sql server instance what are the options to connect to sql server instance? : sql server security
How to encrypt Strored Procedure in SQL SERVER?
Is it possible to have clustered index on separate drive from original table location?
What is raid, and how it can influence database performance?
What is the contrast between sql and pl/sql?
between cast and convert which function would you prefer and why?
What is the difference between value type and reference type?
What is a unique index?
How to insert multiple rows with one insert statement in ms sql server?
What is a linked server in sql server?
What specific conditions database should meet, before you can bulk copy data into it using bcp?
Can you please explain the difference between function and stored procedure?
How to create a simple stored procedure in ms sql server?
Who developed sql server?
what type of index will get created after executing the above statement? : Sql server database administration