Skip to content
Home » SQL Server Interview Question & Answer Quiz on CREATE statement

SQL Server Interview Question & Answer Quiz on CREATE statement




Q 1 > 

Which of the following is the correct order for SQL CREATE TABLE statements?

1> Create table tablename ( col1 datatype1, col2 datatype 2,.. )

2> Create tablename (col1 datatype1 ,col2 datatype2, …)

3> Create table tablename col1 datatype1 , col2 datatyp2 ,..

4> Create tablename  col1 datatype1 , col2 datatyp2 ,..

Answer

1> Create table tablename ( col1 datatype1,… )

 

 

Q 2 > 

What is missing in T-SQL statement ?

Create table employee ( EmpId  ,EmpName , EmpCode) ;

1>Datatypes

2> Constraints

3> 1 & 2

4> none

Answer

1 > 1

 

 

Q 3 > 

Which of the following is the correct to create a primary key on OrderId column in CREATE TABLE statements?

1>Create table Orders ( OrderId Int Primary key , OrderName varchar(50),..)

2> Create table Orders ( OrderId Int  add primary key, OrderName varchar(50),..)

3> Create table Orders ( OrderId Int  , OrderName varchar(50), Primary key (Orderid))

4> 1 & 3

Answer

4 > 1 & 3

 

 

Q 4 > 

Which of the following is the correct  to create a Foreign key in CREATE TABLE statements?

1>

CREATE TABLE tablename

( col1 datatype1 , col2 datatyp2 ,

FOREIGN KEY  [col1,col2…]  REFERENCES [primary key table name] (column name of primary key table) …

);

2>

CREATE TABLE tablename

( col1 datatype1 , col2 datatyp2 ,

FOREIGN KEY  [col1,col2…]  [primary key table name] (column name of primary key table) …

);

3>

CREATE TABLE tablename

( col1 datatype1 , col2 datatyp2 ,

FOREIGN KEY  [col1,col2…]  REFERENCES  (column name of primary key table) …

);

4>none

Answer

1>

CREATE TABLE tablename

( col1 datatype1 , col2 datatyp2 ,

FOREIGN KEY  [col1,col2…]  REFERENCES [primary key table name] (column name of primary key table) …

);

 

 

Q 5 > 

Which of the following is the correct to create a SQL Views ?

1>

create view viewname   as

select column1, column2 , …..

from tablename where condition  ..

2>

create view viewname

select column1, column2 , …..

from tablename where condition  ..

3>

create views viewname   as

select column1, column2 , …..

from tablename where condition  ..

4>

create table view viewname   as

select column1, column2 , …..

from tablename where condition  ..

Answer

1>

create view viewname   as

select column1, column2 , …..

from tablename where condition  ..

 

 

Q 6 > 

Which of the following is the correct to create a SQL Stored Procedures?

1>

create procedurename  (
 @ parameter1   as  datatype 
,@ parameter2  as  datatype
)
as 
begin
sql statement …

2>

create  procedure  procedurename  (
 @ parameter1   as  datatype 
,@ parameter2  as  datatype
)
as 
begin
sql statement …

3>

create proc  procedurename  (
 @ parameter1   as  datatype 
,@ parameter2  as  datatype
)
as 
begin
sql statement …

4> 2 & 3

Answer

4> 2 & 3

Q7 > 

What is missing in Create function statement ?

CREATE FUNCTION  fn_name

( @parameter1  datatype1,  @parameter2  datatype2 , …  )

RETURNSdatatype

AS

BEGIN

 {expression }

END

1>  As after fn_name

2> Return is missing in begin end block

3> 1 & 2

4 > 2

 

Answer

2> Return is missing in begin end block

 

Q 8 > 

Which of the following is the correct to create a SQL Server Database ?

1> create databasename ;

2> create database databasename ;

3> create db databasename;

4> 2 & 3

 

Answer

2> create database databasename ;

 

Q 4 > 

Which of the following is the correct  to create a User Defined Table Type Statement?

1>

Create Type tablename as Table

(

col1 datatype1,

col2 datatype2,

.

)

2 >

Create Type tablename

(

col1 datatype1,

col2 datatype2,

.

)

3>

Create Type tablename as  

(

col1 datatype1,

col2 datatype2,

.

)

4 > none

Answer

1>

Create Type tablename as Table

(

col1 datatype1,

col2 datatype2,

.

)

Also Read.

Sql Server Create table

Sql Server Create database

Sql Server Interview Q & A quiz on Select statement

Sql Server Interview Q & A quiz on Substring()

 

Loading

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from SQL BI Tutorials

Subscribe now to keep reading and get access to the full archive.

Continue reading