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
What are logical database components? : SQL Server Architecture
What is analysis service repository?
What are the tools available in market as an alternative to sql server reporting services?
What do you mean by an execution plan?
What is data block and how to define data block size?
What do you mean by collation recursive stored procedure?
What is store procedure? How do they work?
How to find table changes in sql server?
Why do we backup Active Directory ?
What are audit control procedures?
Explain timestamp datatype?
What are cursors and when they are useful?
How to execute multiple stored procedures at one time in sql server?
Do you know concepts and capabilities of sql server?
How to get a list of columns in a view using the "sp_help" stored procedure?