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.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-06-19 : 09:22:09
|
| Scott Faculak writes "I can't seem to find the syntax to Select by column number? Somewhere I remember that you can create a query without column names, but some formula for the columns number you wish to return. Could you shed some light on this?Scott" |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2002-06-19 : 09:26:28
|
| AFAIK you can't SELECT a column by number, although you can use column numbers in an ORDER BY clause. However, this ability will not be supported in future releases of SQL Server (I believe it's being removed from the ANSI SQL standard) so you should avoid using that syntax.If you're using ADO or another data access layer, the recordset object lets you refer to columns by number:rs.Open "SELECT col1, col2, col3 FROM myTable", connObjresponse.write rs(0) 'zero-based index to columns, returns col1response.write rs(1) 'returns col2response.write rs(2) 'returns col3Edited by - robvolk on 06/19/2002 09:27:02 |
 |
|
|
|
|
|