Showing posts with label SQL. Show all posts
Showing posts with label SQL. Show all posts

Thursday, August 21, 2008

Fetching Values Of Sql Table as Comma Seprated Values In SQL Variable

Declare @Str varchar(2000)

Begin

(Select @Str=COALESCE(@Str, '','') + Cast([Employee_name] as nvarchar(100)) + ','

from dbo.Employee )

Select substring(@Str,0,len(@str))

End

Monday, July 16, 2007

SQL2008 Multiple Insert statement

One of the Difference between the SQL 2005 AND SQL 2008.

SQL2008 gives you the facility to insert multiple rows in a single statements.

--SQL Server 2005
INSERT dbo.EMPLOYEE(SALARY) VALUES (1000)
INSERT dbo.EMPLOYEE(SALARY) VALUES (2000)
INSERT dbo.EMPLOYEE(SALARY) VALUES (3000)
INSERT dbo.EMPLOYEE(SALARY) VALUES (4000)

--SQL Server 2008
INSERT dbo. EMPLOYEE(SALARY) VALUES (1000),(2000),(3000),(4000)

Thanks