Hi,
I am looking for some help in MS SQL server. I want to access the columns of a table without using the names of the colulmns.
Example - SELECT table1.field[1], table1.field[2] FROM table1;
Any information to this effect is much appreciated.
cheers/- PradeepCan you explain how you want to use this information? There are probably ways to get you what you'd like, but there are at least as many really bad answers as really good ones.
-PatP|||Pat, I need to get the value of columns 1 and 2 from the table EMP, while not being bothered as to the names of the columns.|||I'd suggest something like:SELECT c.COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS AS c
WHERE 'table1' = c.TABLE_NAME
AND 1 = c.ORDINAL_POSITIONSee the BOL regarding INFORMATION_SCHEMA.COLUMNS (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_ia-iz_87w3.asp) for more details.
-PatP|||Thanks a million Pat, this is what I was looking for.
Are you a SQL Server DBA?
cheers/- Pradeep|||Heck, I've been called even worse than than SQL DBA!
I answer to just about anything from "Hey you" to "Data Modeler", and everything in between. I tend to refer to myself as a Resident Curmudgeon, which seems about as good a description as any to me!
On a (very slightly) more serious note, yes, SQL DBA is one of the hats that I wear nearly every day.
-PatP|||SQL DataBase Analist|||SQL DataBase AnalistI'm a what-ist ?!?!
-PatP|||i think i can translate ...
ahem.
NEH-HERD.
Scott Davis
"If you are not part of the solution, you are probably 1/5 of the suspension" RDJabarov.|||Now Scott, what the heck does that mean? And when are you planning to have your Margarita? At my funeral?
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment