COALESCE is new function in SQL Server 2005. This is used to create comma-separated value string i.e to create the same resultset with a single SELECT statement. The following code shows how it's done.
DECLARE @EmployeeList varchar(100)
SELECT @EmployeeList = COALESCE(@EmployeeList + ', ', '') +
CAST(Emp_UniqueID AS varchar(5))
FROM SalesCallsEmployees
WHERE SalCal_UniqueID = 1
SELECT @EmployeeList
--Results--
---------
1, 2, 4, 5
The COALESCE function performs the magic here. When @EmployeeList is NULL (the first row processed), it returns an empty string. On subsequent rows, it concatenates the @EmployeeList value with a comma and the current @Emp_UniqueID value.
Things borrower must know about Pre Closing Home loan
-
Most people tend to take a home loan for 15 to 20 years as this usually
offers the lowest home loan interest rates. Now to prepay the loan, you
have to p...
No comments:
Post a Comment