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

Which Dot Net string function is equivalent to get specific character in Sql Server?

NOTE: This is objective type question, Please click question title for correct answer.
Which keyword or character is used to join 2 string in Sql Server?

NOTE: This is objective type question, Please click question title for correct answer.
What do we mean by ParseName in-built function?

ParseName function works as Dot Net Split function ,As Split method is used to separate deliminated values and using index we can get value.ParseName function works exactly same.
The ParseName string function returns the specified part of an object name.
Syntax:-
ParseName('object_name',object_part);

Where object_name is a name of the string object.
object_part is always an integer type.
Give an example of ParseName function?

DECLARE @Fruits VARCHAR(50);

SET @Fruits = 'Mango Apple Orange';

SELECT PARSENAME(REPLACE(@Fruits, ' ', '.'), 3),

PARSENAME(REPLACE(@Fruits, ' ', '.'), 2),

PARSENAME(REPLACE(@Fruits, ' ', '.'), 1)

Output:-
Mango Apple Orange

Here,we have replaced space with Dot(.) and based on Dot positions,we are extracting fruit names.
How to get Age from any Date?

We ahve to write below query:-
DECLARE @DATE_OF_BIRTH AS DATETIME = '2000-07-14';

SELECT (FLOOR(DATEDIFF(DAY,@DATE_OF_BIRTH,GETDATE()) / 365.25)) Age;

Output:-14
We have to divide whole Day by 365.25
Here,July has been passed so output will be 14.
What is the significance of DESCRIBE command in SQL Server?

Just Highlight or Select specific Table Name and then Press ALT + F1 Key Combination .So it will show table structure i.e. primary key,foreign ke relation,index information,identity column and many more.
What is an alternating way of showing Table Structures in Sql Server?

sp_help is the an alternative way of displaying structure of table in Sql Server. sp_help is a system stored procedure.
Syntax:-
exec sp_help table_name;

Give an example of Sp_Help system stored procedure?

exec sp_help employee_master;

Here,employee_master is my table name.
In Sql Server,which command is used to get Stored procedures definition or structure?

NOTE: This is objective type question, Please click question title for correct answer.
Which keyword is used to call Stored Procedure from Query Window?

NOTE: This is objective type question, Please click question title for correct answer.
How to show Indexes which are present in a Tables?

NOTE: This is objective type question, Please click question title for correct answer.
How to display primary and foreign keys information on Tables?

NOTE: This is objective type question, Please click question title for correct answer.
What is the syntax for Deleting primary and foreign keys on tables?

Syntax:-
alter table table_name drop constraint constraint_name;

Which statement is the correct statement for removing column from an existing table in Sql Server?

NOTE: This is objective type question, Please click question title for correct answer.
Which statement is(are) correct about @@Identity function?

NOTE: This is objective type question, Please click question title for correct answer.
What is the return type of @@Identity function?

@@Identity function always returns Numeric Values.
For Example:-
Insert into tbl(col1,col2) values('value1','value2');

Select @@Identity;

Then it will return the last inserted identity column values which is by-default integer.
What would be the output of below query? Select @@Identity;

Output would be Null. Above query returns Null as in current session no rows are inserted in any table.
Which statement is wrong about Union clause?

NOTE: This is objective type question, Please click question title for correct answer.
What do we mean by REPLICATE Function in Sql Server?

REPLICATE is an in-built Sql Server function which is used to repeat a string or character occurrence with specified number of times.

Syntax:-

Replicate(string_character_value,integer_value_to_replicate)


Where,string_character_value is a string to repeat, and
integer_value_to_replicate is number of times the string_character_value to be repeated.

Give an example of REPLICATE function.

Suppose,we want to repeat ant character or string 4 times,then we will write as:-
SELECT REPLICATE('vishal ',4) as Repeated_String;

Output:-
vishal vishal vishal vishal


Below query will return repeated number 5 times.
SELECT REPLICATE('5',5) as Repeated_Number;

Output:-
55555

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