Recently I came across an issue in Sql Server 2005, while running CROSS APPLY. The error says that Incorrect syntax near '.'. I tried to figure out all syntax that I could apply but it did not resolve the issue. Actually we need to set sp_dbcmptlevel level to 90. There are good blog posts for this here and here , which can save your valuable time.
Hello friends, We are in the age of web 2.0. With this, I am going to take next step in web. With this my own space, I will be writing on technical topics, financials which is of most interest to me and about all the new things which I will explore in my journey. Because I believe I am student of life and believe in sharing what I learn... So get ready for many more good things to come...
Scenario:- Suppose You have a table abc (Sal_Id int ,Emp_Id int). The Following Query is fired on the table select Emp_Id FROM abc WHERE Sal_Id=1 Query gives result with following rows 1 2 4 Your requirement is to get these values in a single row. This can be achieved by making use of COALESCE in SQL Server. The above Query can be modified as follows to fetch the rows in required format. DECLARE @EmpList varchar(100) SELECT @EmpList = COALESCE(@EmpList,'') + CAST(Emp_Id AS VARCHAR(3)) FROM abc WHERE Sal_Id=1 select @EmpList This will fetch result as 124 If you want result as a Comma Separated string, change COALESCE function as COALESCE(@EmpList,',' ''). You will get result as 1,2,4