Ads 468x60px

XML AUTO Use in SQL Server for Getting XML as a Result

How get Xml as a result set using select statement?
we can use For XML Auto Keyword
Lets Try


Can you write an query for displaying employee name and salary status like salary greater than 20000 or less then 20000 (not display salary only these string according to their salary)?
Lets try
Here we will use the Case Syntax 
I have written this article after reading Questpond article 
click here for read questpond article based on Case Syntax

other case example

Create Proc spGetEmployeesSorted
@SortCoumn nvarchar(10)

Select [Id],[Name],[Gender],[Salary],[City] 
From   [Employee]
Order by Case When @SortCoumn = 'Id' Then Id End,
                Case When @SortCoumn = 'Name' Then Name End,
                Case When @SortCoumn = 'Gender' Then Gender End,
                Case When @SortCoumn = 'Salary' Then Salary End,
                Case When @SortCoumn = 'City' Then City End

Insert Multiple Rows Using Single Insert Statement : SQLServer2008

How insert multiple record in a table using one insert statement in sqlserver 2008?

SQL server 2005 OLD way
insert into Companies select 'EnigmaSoft'
union all select 'WebCatalyst'
union all select 'Awarebase'

SQL server 2008 NEW way
insert into Companies values('HCL'),('Oracle'),('Infosys')

For more read SqlAuthority Article

Declare @i int = 1 | Diff between SQL Server 2005 and SQL Server 2008

One of the most famous interview question of SQL server is
"What is the diff. between Sqlserver 2005 and Sqlserver 2008"?
Here I am going to describe only 3 differences which is related to Declare and Set Keywords of Sql.

1. You can declare variable and assign the value without using Set keyword in sqlserver 2008. / but not in 2005
2. You can increment the value like c# @i+=1 in sqlserver 2008. / but not in sqlserver 2005
3. You can put the break point for debug query  in sqlserver 2008. / but not in sqlserver 2005
...many other diff but here is only 3 we describing 
Declare @I int = 1
print @i
set @i+=1

Can you drop the database currently you working on? Interview questions

Hey first of all thanx for visit dotnetpoints.
One Impotent Sqlserver Interview Questions is
Can you drop the database currently you working on?
what is your answers?
yes or no?

Lets See:
Here we are going to try to drop the database with name "HH" and current we are using same "HH" database

we can't drop the database current we using. if you fire the drop query then you will got the following error message.
Msg 3702, Level 16, State 3, Line 1
Cannot drop database "YourDBName" because it is currently in use.

Now user other database and execute same query then see what happened

So the answer is No