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

When does below error occur? Msg 208, Level 16, State 1, Line 1 Invalid object name 'dbo.employee_master'.

When we have not set DB, in which the associated table has been created.Then we must set DB first,then we can use query.For setting DB,we can have "USE" keyword followed by DB_Name as shown below:-

Use DB_Name
Select * from db.employee_master;

Then above error will not come, and query will produce result.
Can we have WHERE CLAUSE in SELF JOIN?

Yes. We can write Where Clause in Self Join. As self join joins table itself. So it will produce result based on condition,which we supply in where clause.

For example:-
Select * from employee_master a,employee_master b where a.employee_id = b.employee_id;

How to create Table without using Create Statement?

With the help of Select * Into statement, we can create new table along with rows.

For ex:-

Select * into test from employee_master;

What will be the output of below query? Select Top 50 Percent * From Employee_Master; If Employee_Master is having 11 record.

NOTE: This is objective type question, Please click question title for correct answer.
How to execute below stored procedure? create procedure load_employee_details as Go begin select * from employee_master where status = 'AA'; end

With the help of EXEC in-built SQL Server function we can Execute any user defined Stored Procedures as well as system Stored Procedures.

Syntax is:-

Exec <procedure_name>(parameter_name1,parameter_name2,.....);

For above SP,we will write:-

Exec load_employee_details;

Press F5 to execute SP.

How can you run a job using SQL Server Agent?

NOTE: This is objective type question, Please click question title for correct answer.
How to delete the CLR assembly from SQL Server

NOTE: This is objective type question, Please click question title for correct answer.
What is the purpose of msdb in SQL server?

msdb is a system database available in SQL Server, mainly used by SQL Server Agent to schedule jobs, creating alerts to get the status from jobs and recording operators.
Scheduling information used by SQL Server Agent will be lost in the case of msdb corruption. In turn results to the failure of all scheduled activities.
Which of the following is a component of SQL Server Agent?

NOTE: This is objective type question, Please click question title for correct answer.
What is the purpose of MODEL database?

model is a system database which is available in SQL server. It is used as a template for future user-defined databases. whenever you supposed to create a database in SQL Server model database will provide some default configurations/options.
To check the same thing do the following:
1) Change Recovery Model of model database to FULL ( SQL Server object explorer--> access model db properties --> go to Options Page )
2) Create one sample stored procedure in model database
3) Then, Create new database in SQL Server
4) Now you will get to know that your newly created database will have sample SP which is created in model database and also check the recovery model too
Which of the following is NOT stored in the master database?

NOTE: This is objective type question, Please click question title for correct answer.
DECLARE @UntPrice MONEY = 12345.6789; SELECT FORMAT(@UntPrice, 'C', 'en-US'); What is the output of the above statement

NOTE: This is objective type question, Please click question title for correct answer.
Which of the following functions is a new logical function introduced in SQL Server 2012?

NOTE: This is objective type question, Please click question title for correct answer.
How to write recursive query in SQL Server?

NOTE: This is objective type question, Please click question title for correct answer.
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