Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Other SQL Server Topics (2005)
 solving query

Author  Topic 

svibuk
Yak Posting Veteran

62 Posts

Posted - 2012-02-03 : 07:13:47
having this query which was working fine
but started giving syntax error
need to solve this query to get the result


SELECT a.NAME,(case when (a.XLNAME IS null) OR (a.XLNAME = ' '))
a.NAME else a.XLNAME end) as E_COL ,[order],width,b.column_name,
b.data_type FROM (SELECT * FROM XLS_XLS where status=1 and [order]<>0)
as A Left Join
(SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='STUDENT')
as B ON A.NAME=B.COLUMN_NAME ORDER BY A.[order]

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2012-02-03 : 10:08:26
[code]SELECT x.Name,
CASE
WHEN x.XlName > '' THEN x.XlName
ELSE x.Name
END AS E_COL,
x.[Order],
x.Width,
c.Column_Name,
c.Data_Type
FROM dbo.XLS_XLS AS x
LEFT JOIN INFORMATION_SCHEMA.COLUMNS AS c ON c.Column_Name = x.Name
AND c.Table_Name = 'STUDENT'
WHERE x.[Status] = 1
AND x.[Order] <> 0
ORDER BY x.[Order][/code]


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -