![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, Is there any way how to formulate SQL query to select all columns except column D and E? So if the table has the columns A,B,C,D the result woud contain only columns A,B,C SELECT " * except D,E" FROM myTable Thanks, Lubomir |
#3
| |||
| |||
|
|
Hi, Is there any way how to formulate SQL query to select all columns except column D and E? So if the table has the columns A,B,C,D the result woud contain only columns A,B,C SELECT " * except D,E" FROM myTable Thanks, Lubomir |
#4
| |||
| |||
|
|
Hello, If you want it permamanent then you can create a view and then query the view CREATE VIEW A1 as Select A,B,C from myTable After the creation query the view Select * from A1 THanks Hari "Lubomir" <Lubomir (AT) discussions (DOT) microsoft.com> wrote in message news:A8B69DA2-E5B7-4E91-BCE9-89A673C6CCA9 (AT) microsoft (DOT) com... Hi, Is there any way how to formulate SQL query to select all columns except column D and E? So if the table has the columns A,B,C,D the result woud contain only columns A,B,C SELECT " * except D,E" FROM myTable Thanks, Lubomir |
#5
| |||
| |||
|
|
The problem is, the tables are created on the fly, so I don't know what columns the particular table will have. |
|
From that reason, it would be very convenient to make query like SELECT * and to specify those 2 columns to be exclusive. |
#6
| |||
| |||
|
|
The problem is, the tables are created on the fly, so I don't know what columns the particular table will have. I know however, every table has two columns ("help" columns) that will not be displayed, as they are used for another purposes. From that reason, it would be very convenient to make query like SELECT * and to specify those 2 columns to be exclusive. Thanks, Lubomir "Hari Prasad" wrote: Hello, If you want it permamanent then you can create a view and then query the view CREATE VIEW A1 as Select A,B,C from myTable After the creation query the view Select * from A1 THanks Hari "Lubomir" <Lubomir (AT) discussions (DOT) microsoft.com> wrote in message news:A8B69DA2-E5B7-4E91-BCE9-89A673C6CCA9 (AT) microsoft (DOT) com... Hi, Is there any way how to formulate SQL query to select all columns except column D and E? So if the table has the columns A,B,C,D the result woud contain only columns A,B,C SELECT " * except D,E" FROM myTable Thanks, Lubomir |
#7
| |||
| |||
|
|
On Fri, 4 May 2007 09:37:00 -0700, Lubomir wrote: The problem is, the tables are created on the fly, so I don't know what columns the particular table will have. Hi Lubomir, That is indeed a problem. And it's also a sign that you are using the database in a way that it's not intended to be used - applications that need to create tables on the fly are almost always the result of some bad design decisions. Could you explain in some more detail WHY your application does not have a fixed data model? From that reason, it would be very convenient to make query like SELECT * and to specify those 2 columns to be exclusive. There is no syntax for this in SQL. (And if anyone ever proposes it, I'd vote against it - personally, I'd rather remove the SELECT * than to extend it!) -- Hugo Kornelis, SQL Server MVP My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis |
#8
| |||
| |||
|
|
Hi Hugo, The reason is, that that this application serves more application (like plugins) with their own tables. |
#9
| |||
| |||
|
|
Hi Hugo, The reason is, that that this application serves more application (like plugins) with their own tables. Lubomir "Hugo Kornelis" wrote: On Fri, 4 May 2007 09:37:00 -0700, Lubomir wrote: The problem is, the tables are created on the fly, so I don't know what columns the particular table will have. Hi Lubomir, That is indeed a problem. And it's also a sign that you are using the database in a way that it's not intended to be used - applications that need to create tables on the fly are almost always the result of some bad design decisions. Could you explain in some more detail WHY your application does not have a fixed data model? From that reason, it would be very convenient to make query like SELECT * and to specify those 2 columns to be exclusive. There is no syntax for this in SQL. (And if anyone ever proposes it, I'd vote against it - personally, I'd rather remove the SELECT * than to extend it!) -- Hugo Kornelis, SQL Server MVP My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis |
#10
| |||
| |||
|
|
If you are talking about SQL 2005, then you can write DDL trigger and programically create view or procedure wich select all columns from table exept those 2. Ramunas "Lubomir" <Lubomir (AT) discussions (DOT) microsoft.com> wrote in message news:07134C0B-DBB4-4B60-ADDD-BF2B2E808CB1 (AT) microsoft (DOT) com... Hi Hugo, The reason is, that that this application serves more application (like plugins) with their own tables. Lubomir "Hugo Kornelis" wrote: On Fri, 4 May 2007 09:37:00 -0700, Lubomir wrote: The problem is, the tables are created on the fly, so I don't know what columns the particular table will have. Hi Lubomir, That is indeed a problem. And it's also a sign that you are using the database in a way that it's not intended to be used - applications that need to create tables on the fly are almost always the result of some bad design decisions. Could you explain in some more detail WHY your application does not have a fixed data model? From that reason, it would be very convenient to make query like SELECT * and to specify those 2 columns to be exclusive. There is no syntax for this in SQL. (And if anyone ever proposes it, I'd vote against it - personally, I'd rather remove the SELECT * than to extend it!) -- Hugo Kornelis, SQL Server MVP My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis |
![]() |
| Thread Tools | |
| Display Modes | |
| |