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 happens if null values are involved in datetime operations?
What is a matrix in ssrs?
How many ways to create table-valued functions?
How to list all objects in a given schema?
What is 1nf normalization form?
Is truncate a dml command?
It is important form e to get the information from log files of applications executed by the task scheduler? Does sql studio save these log files? : sql server management studio
can a database be shrunk to 0 bytes, if not, why? : Sql server administration
What is indexing and its types?
What is transaction server isolation?
Tell me what do you understand by a view? What does the with check option clause for a view do?
How to edit table in sql server 2017?
How to create an index on a view?
What is rs.exe utility?
Why SQL Agent is used?