I'm currently doing a project using C#.net and sql server 2005, and I've run into a problem with a select statement! This select statment has to select all column names of a certain table (this is specified in the variable tablename) but i dont want it to include the column names of type int. Please could you help me with this? Here is the select statement i'm currently trying to us but get the error: "System.Data.SqlClient.SqlException: Invalid column name 'DATA_TYPE'."
cmd.CommandText = "SELECT [name] AS [Column name] FROM syscolumns WHERE id = (SELECT id FROM sysobjects WHERE type = 'U' AND [NAME] = '" + tablename + "') AND DATA_TYPE IN ('char', 'varchar', 'nchar', 'nvarchar')";