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 |
|
OldMySQLUser
Constraint Violating Yak Guru
301 Posts |
Posted - 2008-02-01 : 05:22:17
|
| I can use SELECT * to select all the columns in a table. But what if I want to select all the columns in a table except one? |
|
|
mahesh_bote
Constraint Violating Yak Guru
298 Posts |
Posted - 2008-02-01 : 06:46:39
|
quote: Originally posted by OldMySQLUser I can use SELECT * to select all the columns in a table. But what if I want to select all the columns in a table except one?
Then simply don't take that col into Select and instead of writing Select * .... just writeSelect, Col1, Col2, ..... From ....Thanks,Mahesh |
 |
|
|
OldMySQLUser
Constraint Violating Yak Guru
301 Posts |
Posted - 2008-02-01 : 09:23:50
|
| Thanks Mahesh. I've realised that manually entering the column names is the only way to go. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-02-01 : 10:27:31
|
| select column_name+',' from information_schema.columnswhere table_name='table name' and column_name<>'your unwanted column'Use the above to construct selectMadhivananFailing to plan is Planning to fail |
 |
|
|
OldMySQLUser
Constraint Violating Yak Guru
301 Posts |
Posted - 2008-02-01 : 11:55:02
|
| Very nice. Many thanks. |
 |
|
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2008-02-01 : 19:56:53
|
| From within Enterprise Manager you can also right click on the table in the Object Explorer and have the system script out the SELECT statement. It will produce code for every column; you cna eliminate the one or ones you are not interestedin returning.=======================================The only man I know who behaves sensibly is my tailor; he takes my measurements anew each time he sees me. The rest go on with their old measurements and expect me to fit them. -George Bernard Shaw, writer, Nobel laureate (1856-1950) |
 |
|
|
|
|
|