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 |
rajani
Constraint Violating Yak Guru
367 Posts |
Posted - 2006-12-11 : 17:39:03
|
Hi friendsis it possible to get all columns except one in select list ?i know that i can do following to achieve that but there are quite a few columns in that table and dont want to type in all of those columns?select col1,col2 from mytablei mean something like below can be done ?select mytable.* except col3 from mytable |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-12-11 : 17:44:19
|
You should always explicit type all column names in the select list.Peter LarssonHelsingborg, Sweden |
 |
|
nathans
Aged Yak Warrior
938 Posts |
Posted - 2006-12-11 : 17:48:03
|
Yup, I agree with Peso.If you want to achieve what you're describing then you will be headed down the dynamic sql path.Nathan Skerl |
 |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2006-12-11 : 18:01:50
|
Are you just too lazy to type up the columns? If so, you can generate the columns easily in Query Analyzer using the object browserTara Kizer |
 |
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2006-12-11 : 18:02:55
|
Here's some helper code:SELECT Column_Name + ', ' FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='myTable' AND COLUMN_NAME<>'notTheColumnIWant'Change the table and unwanted column name as needed, and copy and paste the results into your code. |
 |
|
rajani
Constraint Violating Yak Guru
367 Posts |
Posted - 2006-12-12 : 20:49:14
|
Thank you very much guys.in Visual foxpro there is a "Except Fields" clause so just wondered if there is something like that available in sql!Cheers |
 |
|
|
|
|