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
Explain raiserror in sql server?
How to include date and time values in sql statements?
What is intellisense?
what type of index will get created after executing the above statement? : Sql server database administration
What is raid? : SQL Server Architecture
What are the advantages of log shipping?
Mention the different types of replication in sql server.
How to update a field in SQL after ALTERING a row?
Tell me what is de-normalization and what are some of the examples of it?
What are the difference between “where” and “having” clause in sql server?
Hi all, can any one please tell me the difference between sql server 2008 and orace 9i
Does an index slow down updates on indexed columns?
Distinguish between commit and rollback?
can an order by clause be used in a creation of a view?
what is the difference between delete table and truncate table commands? : Sql server database administration