select * query excluding one field in sql server

  • Follow


I want to write a SELECT query for all fields except for one field that I 
want to exclude from the select statement.
Let say I have a table containing 150 fields; I want to read 149 fields and 
exclude one field e.g Field_126

Is it possible to get this done without listing 149 fields explicitly?
0
Reply Utf 4/9/2010 10:03:01 PM

Not directly.  Here are a couple of alternatives:

- In SSMS you can right click a table and choose Script Table As > Select To 
 > New Query Editor Window and let SSMS generate the query for you.  Then 
just delete the column(s) you don't want.
- You could create a view that explicitly names just the columns you want to 
return.  Note that using SELECT * is not a best practice in production code.

-- 
Thanks

Michael Coles
SQL Server MVP
Author, "Expert SQL Server 2008 Encryption" 
(http://www.apress.com/book/view/1430224649)
----------------


"Ryan" <Ryan@discussions.microsoft.com> wrote in message 
news:A5E11479-183E-4A7D-93B0-2CCEB3668722@microsoft.com...
> I want to write a SELECT query for all fields except for one field that I
> want to exclude from the select statement.
> Let say I have a table containing 150 fields; I want to read 149 fields 
> and
> exclude one field e.g Field_126
>
> Is it possible to get this done without listing 149 fields explicitly? 

0
Reply Michael 4/9/2010 11:28:07 PM


1 Replies
808 Views

(page loaded in 8.14 seconds)

Similiar Articles:
















7/20/2012 12:37:51 PM


Reply: