sql server - Can i user a where statement by first column? -


possible duplicate:
is possible select sql server data using column ordinal position

not sure if title help, i'm trying create general function , wondering if use column position in statements instead of column name. example

select * table myid=1

would become this

select * table [0]=1

does make sense? doable? guys.

btw - using mssql 2005-2008

i think must column name of column position , generate execute query column name. below code column name of column position , execute query:

declare @tablename  varchar(100) declare @columnposition int  set @tablename = 'table1' set @columnposition = 1  declare @columnname varchar(250) select @columnname  = column_name information_schema.columns table_name = @tablename , ordinal_positio = @columnposition  declare @query varchar(250) set @query = 'select * ' + @tablename + ' '+ @columnname + ' = 1' exec (@query) 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -