How to get the columns except one
-
is it possible to get the data of table except for one column? that is, if I have a table with column names ID, Name, Address, ... How can I get the data of all columns except for ID column? and, how to get the column names(not the data) ? for table names I found the following: Select * from sysobjects where [type] in ('U')
-
is it possible to get the data of table except for one column? that is, if I have a table with column names ID, Name, Address, ... How can I get the data of all columns except for ID column? and, how to get the column names(not the data) ? for table names I found the following: Select * from sysobjects where [type] in ('U')
Exceter wrote: is it possible to get the data of table except for one column? that is, if I have a table with column names ID, Name, Address, ... How can I get the data of all columns except for ID column? Only by specifying all the columns. Note that using the
*
operator can be a bit costly, because the server has to enumerate the columns - it's usually better to specify them all anyway. and, how to get the column names(not the data) ? for table names I found the following: Select * from sysobjects where [type] in ('U') See http://msdn.microsoft.com/msdnmag/issues/03/08/CodeGeneration/default.aspx[^] for more details. -
Exceter wrote: is it possible to get the data of table except for one column? that is, if I have a table with column names ID, Name, Address, ... How can I get the data of all columns except for ID column? Only by specifying all the columns. Note that using the
*
operator can be a bit costly, because the server has to enumerate the columns - it's usually better to specify them all anyway. and, how to get the column names(not the data) ? for table names I found the following: Select * from sysobjects where [type] in ('U') See http://msdn.microsoft.com/msdnmag/issues/03/08/CodeGeneration/default.aspx[^] for more details.Mike Dimmick wrote: How can I get the data of all columns except for ID column? Just want to add that it's a bad practice to use
SELECT *
. Think what will happen with your code if you rename some of your table columns or reorder them. Alexandre Kojevnikov MCAD charter member Leuven, Belgium -
Mike Dimmick wrote: How can I get the data of all columns except for ID column? Just want to add that it's a bad practice to use
SELECT *
. Think what will happen with your code if you rename some of your table columns or reorder them. Alexandre Kojevnikov MCAD charter member Leuven, BelgiumAlexandre Kojevnikov wrote: Think what will happen with your code if you rename some of your table columns or reorder them. So what? If you'll specify all columns in SELECT, you will still need to change your code, then what's the matter? Mike actually pointed the right issue about performance of "*" Philip Patrick Web-site: www.stpworks.com "Two beer or not two beer?" Shakesbeer
-
Alexandre Kojevnikov wrote: Think what will happen with your code if you rename some of your table columns or reorder them. So what? If you'll specify all columns in SELECT, you will still need to change your code, then what's the matter? Mike actually pointed the right issue about performance of "*" Philip Patrick Web-site: www.stpworks.com "Two beer or not two beer?" Shakesbeer
Philip Patrick wrote: you will still need to change your code Exactly. But if you don't use
SELECT *
you will get errors in your SQL query and will have one more possibility to think about consequences of column renaming and adapt the client code appropriately. WithSELECT *
you might forget about adapting the client code. And in many cases you won't even see compile-time errors. If you are just reordering columns, you won't have to change anything. Performance is also an important issue of course. Alexandre Kojevnikov MCAD charter member Leuven, Belgium