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 / saravanan sankar
CREATE PROCEDURE create_table
@table varchar(20)
AS
BEGIN
declare @string varchar(5000)
set @string = 'CREATE TABLE '+ @table +'(id int,name char(20))'
END
exec(@string)
//FIRST RUN PROCEDURE ABOVE AND THEN EXECUTES
EXEC create_table 'TABLE1'
| Is This Answer Correct ? | 8 Yes | 1 No |
Post New Answer View All Answers
What is the syntax for encrypting a column in SQL Server?
If you are given access to a SQL Server, how do you find if the SQL Instance is a named instance or a default instance?
What is explicit mode in sql server?
Explain about Views?
How many levels of sp nesting is possible?
What is the purpose of indexing?
Explain mixed authentication mode of sql server?
Explain how to integrate the ssrs reports in application?
Explain concepts of analysis services?
How to find the login name linked to a given user name?
Difference between report and query parameter. Why do we need different type of parameter?
Explain primary key and foreign key constraints?
Explain an incremental backup?
Explain the disadvantages of cursors?
What is the difference between char and varchar2 datatype in sql?