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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Other SQL Server Topics (2005)
 solving query
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

svibuk
Yak Posting Veteran

62 Posts

Posted - 02/03/2012 :  07:13:47  Show Profile  Reply with Quote
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

Sweden
30421 Posts

Posted - 02/03/2012 :  10:08:26  Show Profile  Visit SwePeso's Homepage  Reply with Quote
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]



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000