Sql Server Interview Questions and Answers (1758) - Page 73

Give some examples of Modulo Operator.

We can see so many examples of Modulo Operator as:-
select 12%2;

0
Select 15%3; 

0
Select 10%9;

1
Select price % discount as reminder from table_name;

Which statement is/are true about IsNull function?

NOTE: This is objective type question, Please click question title for correct answer.
Which statement is correct about IsDate Function?

NOTE: This is objective type question, Please click question title for correct answer.
What does SCOPE_IDENTITY function does in Sql Server?

SCOPE_IDENTITY returns the Last Identity Value for any table in the Same Session and the Same Scope.
Syntax:-
Select Scope_Identity();


For Example:-
insert into tbl(col1,col2) values('value1','value2');

Select Scope_Identity();

Output:-Would be Last Inserted Identity Column Value.
Which statement is True about IDENT_CURRENT function in Sql Server?

NOTE: This is objective type question, Please click question title for correct answer.
Give an example of IDENT_CURRENT function.

Select Ident_Current('Employee_Master');

Output :- 2500 -> 2500 is the last row identity value.
Select Ident_Current('Project_Master');

Output :- 100 -> 100 is the last row identity value.
Which statement is correct about NewId() function?

NOTE: This is objective type question, Please click question title for correct answer.
What is the use of DATEPART function in Sql Server?

DATEPART function is used to get part of the specified date.
Syntax:
DATEPART(datepart,date);

Where, datepart specifies the part of the date to return.
date is an expression that returns a datetime or smalldatetime value, or a character string in a date format.

Which statement is/are correct about Delete command?

NOTE: This is objective type question, Please click question title for correct answer.
Which statement is/are correct about Truncate command?

NOTE: This is objective type question, Please click question title for correct answer.
Which statement is/are correct about Derived Table?

NOTE: This is objective type question, Please click question title for correct answer.
How to get primary key with constraint name?

Write below query:-
SELECT T.Table_Name ,TC.Constraint_Name, KCU.Column_Name AS 'Primary_Key_Column_name'

FROM INFORMATION_SCHEMA.TABLES T
INNER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS TC
ON T.table_name=TC.table_name
INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE KCU
ON KCU.Constraint_Name = TC.Constraint_Name
WHERE OBJECTPROPERTY(OBJECT_ID(T.TABLE_NAME),'TableHasPrimaryKey')=1
AND T.TABLE_TYPE='BASE TABLE'
AND TC.CONSTRAINT_TYPE='primary key'
AND T.Table_Name='test1';

Fetching only current date in MySql is called as?

NOTE: This is objective type question, Please click question title for correct answer.
Fetching only time in MySql is called as?

NOTE: This is objective type question, Please click question title for correct answer.
Fetching both current date and time in MySql is called as?

NOTE: This is objective type question, Please click question title for correct answer.
What type of join is required when we want to include rows that do not have matching values?

NOTE: This is objective type question, Please click question title for correct answer.
What is the use of WaitFor in Sql Server?

WaitFor is used to block the execution of a batch,stored procedure, or transaction until a specified time or time interval is reached,or we can say that a specified statement modifies or returns at least one Row.
What is WaitFor Time in Sql Server?

WaitFor Time is used to wait untill a specified Time of a Day.When Sql Server encounters WaitFor Time,then it pauses operation of a Sql statement until the next occurance of a specified time within a 24-hour interval.Once the particular time reaches,then it starts execution.
Syntax:-
WaitFor Time Time

What is WaitFor Delay in Sql Server?

WaitFor Delay is used to wait a specified Period of a Time. When Sql Server encounters WaitFor Delay,then it immediately pauses operation of a Sql statement.It does not move to the next command or statement until the specified period of time has elapsed.Once the specified Interval has elapsed,Sql Server resumes the execution of Sql Statement,starting with the command immediately after the Waitfor Delay Command.
Syntax:-
WaitFor Delay period_of_Time

Give any example of WaitFor Time command?

WaitFor Time '4:00';

--4 A.M.
DECLARE @DateTime DATETIME

SET @DateTime = DATEADD(s,9,GETDATE()) //9 seconds
SELECT GETDATE() CurrentTime
WaitFor Time @DateTime
SELECT GETDATE() CurrentTime;

Found this useful, bookmark this page to the blog or social networking websites. Page copy protected against web site content infringement by Copyscape

 Interview Questions and Answers Categories