| 
			
				|   | 
			
				
                                            
                                                SQL Server interview question notes: - Raise error
                                            
                                             
                                            
                                                  Point 1:-  RAISERROR is used to raise error / warning back to the application or a catch block. 
  Point 2:-  Syntax of RAISERROR is as below 
 RAISERROR (@Messageid -- Error message number stored in Sys.messages table
           @ErrorSeverity, -- Severity ( 0-25)
           @ErrorState -- State
	   @ErrorMessage, -- Error message string
	   );
 
  Point 3:-  You can raise system error message or user defined error message. For user defined error messages it should be greater than 500 
                                            
                                         | 
			
				
                                            
                                                Can i Rollback the Table DataTypes while using Transactions in sql server?
                                            
                                             
                                            
                                                Table data types are unaffected by rollback statements when using transactions.     Example:      begin transaction  declare @emp  table (empid int)  insert into @emp values(10);  insert into @emp values(20);  rollback     select * from @emp  --------------------------------  10  20     even though you rollback the data table variables will persist the data.  
                                            
                                         | 
			
				
                                            
                                                Cascading referential integrity in sql server
                                            
                                             
                                            
                                                 
What is Cascading referential integrity and when we use it  
		 
		 
Can we delete the parent  
                                            
                                         | 
			
				
                                            
                                                SET ANSI_NULLS explanation
                                            
                                             
                                            
                                                his option specifies the setting for ANSI NULL comparisons. When this is on, any query that compares 
                                            
                                         | 
			
				
                                            
                                                Index in SQL
                                            
                                             
                                            
                                                ndex in sql is created on existing tables to retrieve the rows quickly.   If we don't create any ind 
                                            
                                         | 
			
				
                                            
                                                List All The Constraint of all tables of Database
                                            
                                             
                                            
                                                ith below query we may find out the constraints of every table. It is useful in case when we want to 
                                            
                                         | 
			
				
                                            
                                                Allow double quotes in Store procedures
                                            
                                             
                                            
                                                o allow double quotes in store procedures, Below line need to put above the procedure. 
 SET QUOTED 
                                            
                                         | 
			
				
                                            
                                                Add Day, Month or Year in date column in sql server
                                            
                                             
                                            
                                                e can add date in sql server with DATEADD function. Example is as below.
  
 Syntax:  DATEADD (dat 
                                            
                                         | 
			
				
                                            
                                                What is the difference between char, nchar, varchar, and nvarchar in MSSQL?
                                            
                                             
                                            
                                                  
	nchar and nvarchar can store Unicode characters.  
	char and varchar cannot store Unicode char 
                                            
                                         | 
			
				
                                            
                                                SQL Server interview question:- Mention SSIS, SSAS and SSRS?
                                            
                                             
                                            
                                                 All these 3 things are related to Business intelligence. Business intelligence is all about making meaning of your data, forecasting using that data, making more business sense from the data. 
 In order to do the same we first need to collect data, analyze it and then display it to the stake holders. 
 The collection of data is done by using SSIS. 
 The data analyzation part is done by SSAS. 
 The displaying of data is done by using SSRS or reporting services. 
 Below is a simple video in  
                                            
                                         | 
			
				
                                            
                                                SQL Server interview questions: - Elaborate two types of indexes and explain them?
                                            
                                             
                                            
                                                 This is the  SQL Server interview questions  most asked during the interview so do revise before you go for the interview. 
 There are basically two types of indexes:- 
 
	 Clustered Indexes. 
	 Non-Clustered Indexes. 
 
 Every thing is same for both the indexes i.e. it uses “B-TREE” for searching data. However, the main difference is the way it stores physical data 
 In clustered index, the non-leaf level actually points to the actual data.    
  Figure: - Clustered Index Architecture  
                                            
                                         | 
			
				
                                            
                                                How to check that sql instance is running on PC
                                            
                                             
                                            
                                                
Some time sql server installs properly on pc but it does not connects.
  
One of the reason is 1 
                                            
                                         | 
			
				
                                            
                                                Turning Off and On Identity Column in SQL Server
                                            
                                             
                                            
                                                I have been moving over the data from one database to another. Issue came when data was entering in  
                                            
                                         | 
			
				
                                            
                                                Insert Multiple records with single Insert statement in sql server
                                            
                                             
                                            
                                                
insert into persons 
( 
p_id, First_Name, Last_Name, Address, city 
) 
values 
( 
'2', 'Shya 
                                            
                                         | 
			
				
                                            
                                                .NET and SQL Server interview questions -Show Practically Sql Server Views are updatable?
                                            
                                             
                                            
                                                
 
	 Answer:  
	  
	View is a virtual table, which can contains data (rows with columns) from 
	one or more table and you can retrieve data from a view. 
	 
	Let’s demonstrate a simple example in which we will see that how to create a 
	view on single table and will also see that if we update the view the 
	respective table on which the view is created  is updated or not. 
	 
	Now let first see how to create view. 
	 
	Go to View folder in SQL Server > Right click on it > 
                                            
                                         | 
			
				
                                            
                                                .NET and SQL Server interview questions - Show us top 10 salaries with names of employees in SQL?
                                            
                                             
                                            
                                                  
	 Answer:  
	  
	Let’s see a simple example to see, how exactly we can obtain entire employee 
	name who obtains top 10 salaries. 
	 
	Assuming that we have following table for Employee. 
	 
	  
		  
			  EmpId  
  
			  EmpName  
  
			  EmpSalary  
  
		 
		 
			 1 
			 Alok 
			 20000 
		 
		 
			 2 
			 Ashok 
			 30000 
		 
		 
			 3 
			 Anand 
			 25000 
		 
		 
			 4 
			 Akash 
			 18000 
		 
		 
			 5 
			 Prasad 
			 33000 
                                            
                                         | 
			
				
                                            
                                                .NET and SQL Server interview questions - Which query is used to merge two different columns into single column?
                                            
                                             
                                            
                                                
 Answer:    
let's us assume that we have the following table of Employee. 
 
  
	  
		  Emp_Id  
		  Emp_Name  
		  Emp_Salary_2010  
		  Emp_Salary_2011  
	 
	 
		 1 
  
		 Shiv 
		 17000 
		 19000 
	 
	 
		 2 
  
		 Raju  
  
		 13500 
		 15000 
	 
	 
		 3 
  
		 Sham 
		 15000 
		 18000 
	 
	 
		 4 
  
		 Moosa 
		 11000 
		 14000 
	 
	 
		 5 
  
		 Feroz 
		 12000 
		 16000 
	 
  
      & 
                                            
                                         | 
			
				
                                            
                                                NET and Sql Server interview questions - Write a SQL query in order to merge two different columns into single column?
                                            
                                             
                                            
                                                
 
	 Answer:   
  This is one of the most typical question asked by the interviewers. 
	 Let’s us assume that we have the following two table of Product and 
	Vendor with their respective fields like below. 
	ProductId    ProductName    Cost            //Product table 
	VendorID     VendorName     ProductId     //Vendor table  
	 Now l 
                                            
                                         | 
			
				
                                            
                                                Create queries of database tables with its data (Microsoft SQL Server Database Publishing Wizard 1.1 )
                                            
                                             
                                            
                                                
Some time you may have situation that you need to import the data from sql server. If you are usin 
                                            
                                         | 
			
				
                                            
                                                .NET and SQl Server interview questions :- Testing of SQL CASE syntax capability with complicated SQL query.
                                            
                                             
                                            
                                                
   Answer:        
 Let's us assume that we have the following table of Employee. 
 
   
   
     Emp_Id       
   
   
     Emp_Name       
   
   
     Emp_Salary       
   
  
  
   
    1    
   
   
     Shiv       
   
   
    17000    
   
  
  
   
    2    
   
   
     Raju       
   
   
    13500    
   
  
  
   
    3    
   
   
    Sham    
   
   
    15000    
   
  
  
   
    4    
   
   
     Moosa       
   
    
                                            
                                         | 
			
				
                                            
                                                .NET and SQL Server interview questions - Can you get second highest salary from the table?
                                            
                                             
                                            
                                                
 Answer:  
  
Let's us assume that we have the following table of Employee. 
 
  
	  
		  Emp_Id  
  
		  Emp_Name  
  
		  Emp_Salary  
  
	 
	 
		 1 
  
		 Shiv 
  
		 17000 
  
	 
	 
		 2 
  
		 Raju 
  
		 13500 
  
	 
	 
		 3 
  
		 Sham 
  
		 15000 
  
	 
	 
		 4 
  
		 Moosa 
  
		 11000 
  
	 
	 
		 5 
  
		 Feroz 
  
		 12000 
  
	 
  
  
                                            
                                         | 
			
				
                                            
                                                Insert Multiple records with single Insert statement
                                            
                                             
                                            
                                                For entering data in table we will write below command.   insert into persons ( p_id, First_Name, La 
                                            
                                         | 
			
				
                                            
                                                Update Only Year in date in sql server with query
                                            
                                             
                                            
                                                
I need to update the year only and keep the rest same. Here under is my date format:   
2011-03-1 
                                            
                                         | 
			
				
                                            
                                                Query to Find table name from Database having specific column
                                            
                                             
                                            
                                                
 
Some days ago I need to find a table name where a column exist or not. There were around 100 tab 
                                            
                                         | 
			
				
                                            
                                                Create an index with Drop existing index on table
                                            
                                             
                                            
                                                If you want to Create an cluster index on table then there should not be any index on that table. So 
                                            
                                         | 
			
				
                                            
                                                Send mail using Sql server
                                            
                                             
                                            
                                                
To send the mail using sql server. you need to enable the Object creation permission, because for  
                                            
                                         | 
			
				
                                            
                                                DDL, DML, DCL, TCL Commands
                                            
                                             
                                            
                                                DDL 
 Data Definition Language (DDL) statements are used to define the database structure or schema 
                                            
                                         | 
			
				
                                            
                                                Truncate, Delete & DROP
                                            
                                             
                                            
                                                Truncate & Delete 
 1 The DELETE command is used to remove rows from a table. A WHERE clause ca 
                                            
                                         | 
			
				
                                            
                                                Operators
                                            
                                             
                                            
                                                Operator       Description =      & 
                                            
                                         | 
			
				
                                            
                                                Working with date time in sql server
                                            
                                             
                                            
                                                
It is common to handle the date time in sql server. Common scenario where date time is used are :  
                                            
                                         | 
			
				 |