Sql Server Interview questions part-1
Published by
chandrasekhar
-
On
7:32 PM
// This post haved
0
comments
//
Sql server Experience Questions-
Sql server Interview questions
1)Difference between Primary Key and unique key ?
Ans)
Primary Key Restrict duplicate values and null values each table can have only one primary key,default clustered index is the primary key.
unique key restrict duplicate values and allow only one null value. default non clustered index is an unique key
------------------------------------
2)What is the clause that specifies a condition for a group or an aggregate?
Ans)
Select from following answers:
A. Distinct
B. Where clause
C. Exists
D. Having Clause
Having Clause
This is how we can create a condition laid on a group or aggregate
Example :
SELECT column_name, aggregate_function(column_name)
FROM table_name
WHERE column_name operator value
GROUP BY column_name
HAVING aggregate_function(column_name) operator value
------------------------------------------------------------------------
3) Which command removes all the rows from the table without logging individual row deletions ?
Ans)
Select from following answers:
A. Truncate
B. delete
C. drop
D. Alter
Truncate will not log individual row deletion.
Here is an example of how we can count the rows before and after truncate
SELECT COUNT(*) AS BeforeTruncateCount FROM MyTable.MyJob;
TRUNCATE TABLE MyTable.MyJob;
SELECT COUNT(*) AS AfterTruncateCount FROM MyTable.MyJob;
---------------------------------------------------------------------
4) What is the command that is used to set a set of privileges that can be granted to users or different roles?
Ans)
Select from following answers:
A. Create Authority
B. Create Grant
C. Create Role
D. Create Authentication
Role Command is used to set the set of privileges which can be granted to users.
An example:
CREATE ROLE editors AUTHORIZATION db_SecurityServices;
Ans)
Primary Key Restrict duplicate values and null values each table can have only one primary key,default clustered index is the primary key.
unique key restrict duplicate values and allow only one null value. default non clustered index is an unique key
------------------------------------
2)What is the clause that specifies a condition for a group or an aggregate?
Ans)
Select from following answers:
A. Distinct
B. Where clause
C. Exists
D. Having Clause
Having Clause
This is how we can create a condition laid on a group or aggregate
Example :
SELECT column_name, aggregate_function(column_name)
FROM table_name
WHERE column_name operator value
GROUP BY column_name
HAVING aggregate_function(column_name) operator value
------------------------------------------------------------------------
3) Which command removes all the rows from the table without logging individual row deletions ?
Ans)
Select from following answers:
A. Truncate
B. delete
C. drop
D. Alter
Truncate will not log individual row deletion.
Here is an example of how we can count the rows before and after truncate
SELECT COUNT(*) AS BeforeTruncateCount FROM MyTable.MyJob;
TRUNCATE TABLE MyTable.MyJob;
SELECT COUNT(*) AS AfterTruncateCount FROM MyTable.MyJob;
---------------------------------------------------------------------
4) What is the command that is used to set a set of privileges that can be granted to users or different roles?
Ans)
Select from following answers:
A. Create Authority
B. Create Grant
C. Create Role
D. Create Authentication
Role Command is used to set the set of privileges which can be granted to users.
An example:
CREATE ROLE editors AUTHORIZATION db_SecurityServices;
1)Difference between Primary Key and unique key ?
Ans)
Primary Key Restrict duplicate values and null values each table can have only one primary key,default clustered index is the primary key.
unique key restrict duplicate values and allow only one null value. default non clustered index is an unique key
------------------------------------
2)What is the clause that specifies a condition for a group or an aggregate?
Ans)
Select from following answers:
A. Distinct
B. Where clause
C. Exists
D. Having Clause
Having Clause
This is how we can create a condition laid on a group or aggregate
Example :
SELECT column_name, aggregate_function(column_name)
FROM table_name
WHERE column_name operator value
GROUP BY column_name
HAVING aggregate_function(column_name) operator value
------------------------------------------------------------------------
3) Which command removes all the rows from the table without logging individual row deletions ?
Ans)
Select from following answers:
A. Truncate
B. delete
C. drop
D. Alter
Truncate will not log individual row deletion.
Here is an example of how we can count the rows before and after truncate
SELECT COUNT(*) AS BeforeTruncateCount FROM MyTable.MyJob;
TRUNCATE TABLE MyTable.MyJob;
SELECT COUNT(*) AS AfterTruncateCount FROM MyTable.MyJob;
---------------------------------------------------------------------
4) What is the command that is used to set a set of privileges that can be granted to users or different roles?
Ans)
Select from following answers:
A. Create Authority
B. Create Grant
C. Create Role
D. Create Authentication
Role Command is used to set the set of privileges which can be granted to users.
An example:
CREATE ROLE editors AUTHORIZATION db_SecurityServices;
Ans)
Primary Key Restrict duplicate values and null values each table can have only one primary key,default clustered index is the primary key.
unique key restrict duplicate values and allow only one null value. default non clustered index is an unique key
------------------------------------
2)What is the clause that specifies a condition for a group or an aggregate?
Ans)
Select from following answers:
A. Distinct
B. Where clause
C. Exists
D. Having Clause
Having Clause
This is how we can create a condition laid on a group or aggregate
Example :
SELECT column_name, aggregate_function(column_name)
FROM table_name
WHERE column_name operator value
GROUP BY column_name
HAVING aggregate_function(column_name) operator value
------------------------------------------------------------------------
3) Which command removes all the rows from the table without logging individual row deletions ?
Ans)
Select from following answers:
A. Truncate
B. delete
C. drop
D. Alter
Truncate will not log individual row deletion.
Here is an example of how we can count the rows before and after truncate
SELECT COUNT(*) AS BeforeTruncateCount FROM MyTable.MyJob;
TRUNCATE TABLE MyTable.MyJob;
SELECT COUNT(*) AS AfterTruncateCount FROM MyTable.MyJob;
---------------------------------------------------------------------
4) What is the command that is used to set a set of privileges that can be granted to users or different roles?
Ans)
Select from following answers:
A. Create Authority
B. Create Grant
C. Create Role
D. Create Authentication
Role Command is used to set the set of privileges which can be granted to users.
An example:
CREATE ROLE editors AUTHORIZATION db_SecurityServices;
0 comments: