ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Do you have a collection of Interview Questions and interested to share with us!!
Please send that collection to along with your userid / name. ThanQ
Google
 
Categories  >>  Software  >>  Databases  >>  SQL Server
 
 


 

 
 Oracle interview questions  Oracle Interview Questions
 SQL Server interview questions  SQL Server Interview Questions
 MS Access interview questions  MS Access Interview Questions
 MySQL interview questions  MySQL Interview Questions
 Postgre interview questions  Postgre Interview Questions
 Sybase interview questions  Sybase Interview Questions
 DB Architecture interview questions  DB Architecture Interview Questions
 DB Administration interview questions  DB Administration Interview Questions
 DB Development interview questions  DB Development Interview Questions
 SQL PLSQL interview questions  SQL PLSQL Interview Questions
 Databases AllOther interview questions  Databases AllOther Interview Questions
Question
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?

 Question Submitted By :: Monty
I also faced this Question!!     Rank Answer Posted By  
 
  Re: 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
# 1
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 ?    3 Yes 1 No
Saravanan Sankar
 
  Re: 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
# 2
hello Saravanan Sankar
thank you for your answer
 
Is This Answer Correct ?    1 Yes 0 No
Monty
[Reliance]
 
 
 
  Re: 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
# 3
Here is the solution...

create proc CREATE_TABLE
@TableName varchar(50)
as
begin
declare @String nvarchar(max)
set @String='create table '+@TableName +'(ID int,Name 
varchar(50))'
execute sp_executesql @String
end
 
Is This Answer Correct ?    1 Yes 0 No
Veeresh Kethari
 
  Re: 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
# 4
create procedure create_table
@table1 varchar(20)
as
Begin

Declare  @table table
(
id int,
name char(20)
)
end

If you refer question only syntax error is there!!! as table
variable can not use using create command.
 
Is This Answer Correct ?    1 Yes 0 No
Pradip Jain
 

 
 
 
Other SQL Server Interview Questions
 
  Question Asked @ Answers
 
Accidentally i deleted my table. How can i get that table?  4
What is a deadlock and what is a live lock? How will you go about resolving deadlocks? Microsoft1
I have a table in which phno is one of the columns.i do have some values in tht phno column.i need to update phno column values with 0(zero) as prefix.give me a correct solution plz... Value-Labs5
From where can you change the default port?  3
i have a table student like sname ----- ram ram ram raj raj raj i need the output like sname ----- ram raj ram raj ram raj IBM7
how to rename the table  3
what is difference between primary key and Unique  8
Let us say the SQL Server crashed and you are rebuilding the databases including the master database what procedure to you follow?  2
We create an index to fast the search. How it fast the query? Do we write any special keyword with query?  3
Can I remove the default constraint columns in SQL SERVER? Value-Labs3
Define candidate key, alternate key, composite key.  9
IN Vs OR operator which is best to use sql server.  3
What are Magic Table? Evalueserve15
what is the importence of the trigger in sqlserver2000? ATI1
What is the basic functions for master, msdb, tempdb databases? CSC2
What r sql reporting services and analysis services? how can we use it. Microsoft2
Which system table contains information on constraints on all the tables created?  2
how to know Who Is Blocking Your SQL Server?  3
What is Transaction?  2
How do you use DBCC statements to monitor various aspects of a SQL server installation?  1
 
For more SQL Server Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com