troubleshooting Question

MS SQL Server shorthand (function or something) to refer to specific columns

Avatar of ttist25
ttist25 asked on
Microsoft SQL ServerSQL
5 Comments1 Solution84 ViewsLast Modified:
Hey there,

I'm working with a table that has about 200 columns (seems like I am ALWAYS doing that).  
I'd like to do something quick that would allow me to refer to columns in "groups" and have my select return just the columns that pertain to that group.  

For instance, if I wanted to write a select statement that brought back all of the possible address related fields from my table, instead of saying:
SELECT Address1Street, Address1City, Address1State, Address1ZIP, Address2Street, Address2City, Address2Zip, Address3Street etc etc.
I would just say something like
SELECT @AddressFields FROM MyTable and it would grab all the address related fields.  

I'm thinking like a lookup table of fields and groups and an SP or something?  

No big deal - I probably just spent more time thinking about it and writing this question than it's worth.  Just wondering if anyone had a cool trick they've used to make that easier.  

Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros