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


Please Help Members By Posting Answers For Below Questions

If you lose rights to your sql server instance what are the options to connect to sql server instance? : sql server security

527


How to encrypt Strored Procedure in SQL SERVER?

545


Is it possible to have clustered index on separate drive from original table location?

509


What is raid, and how it can influence database performance?

565


What is the contrast between sql and pl/sql?

615






between cast and convert which function would you prefer and why?

525


What is the difference between value type and reference type?

543


What is a unique index?

519


How to insert multiple rows with one insert statement in ms sql server?

582


What is a linked server in sql server?

567


What specific conditions database should meet, before you can bulk copy data into it using bcp?

527


Can you please explain the difference between function and stored procedure?

534


How to create a simple stored procedure in ms sql server?

513


Who developed sql server?

520


what type of index will get created after executing the above statement? : Sql server database administration

529