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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Using wildcards to select fields

Author  Topic 

Crowson
Starting Member

2 Posts

Posted - 2008-06-23 : 14:38:38
I have a really large table with many Proposal fields and corresponding approval fields.

Propose1
Approve1
Propose2
Approve2

Would it be good practice or even possible for me to select all proposal fields using a wildcard somehow within the select statement. If it is ok, how would I go about doing it?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-06-23 : 14:40:05
You could use * to return all columns, but that's a bad practice. You can't use * to return a subset of columns.

Why have you designed a table like this? Are you familiar with database normalization?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2008-06-23 : 14:43:14
I would right-click on the table in Management Studio and then
select Script as --> Select To and then get rid of the columns you
don't need.

Jim
Go to Top of Page

Crowson
Starting Member

2 Posts

Posted - 2008-06-23 : 14:46:22
No, this is not normalized to the third form, but I can't think of how it would happen.

I'm attempting to take a paper form and use it within a small database system. There are many steps, each step having a proposed completion date and an actual completion date. Both of these dates are separate fields within the form. There are also other fields that will be used that refer to other information.

If you can think of how to set this up in multiple tables please let me know.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-06-23 : 16:09:55
Or make use of the result

Select column_name+',' from information_schema.tables
where table_name='your table'

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

rohitkumar
Constraint Violating Yak Guru

472 Posts

Posted - 2008-06-23 : 16:31:22
you cannot use a wild card to get selective columns.

you can have another table with form_id, step_id, proposed_start_date, actual_start_date, user_id
Go to Top of Page
   

- Advertisement -