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 2000 Forums
 SQL Server Development (2000)
 retrieving specific Columns with select

Author  Topic 

sg2255551
Constraint Violating Yak Guru

274 Posts

Posted - 2006-07-25 : 22:53:56
hi

How do i retrieve columns that starts with for example letter F and A and B

I have tried something like:

Select F.*, A.*, B.* from tblDemo

BOL does not have anything on that.

Thanks

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-07-25 : 23:11:30
You have to give the name of the column in your select. You can't use a wildcard.


CODO ERGO SUM
Go to Top of Page

sg2255551
Constraint Violating Yak Guru

274 Posts

Posted - 2006-07-25 : 23:20:52
hi

I have a table with dynamic columns meaning every month it increases by maybe about 40. I have created a view which excel would connect to for pivot table. Initially i have select all columns that start with F,A and B but as it increases, i do not want to administter in the view by reselecting it. Is there anyway? Thanks
Go to Top of Page

LoztInSpace
Aged Yak Warrior

940 Posts

Posted - 2006-07-26 : 01:45:56
Normalise your data. You are clearly missing some additional data and are trying to substitute it using the column name.
At your present rate, you'll have an unmanageable and possibly uncreatable table within a year.
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2006-07-26 : 08:47:03
Holy crap. That is a *horrible* design. Please follow LztInSpace's advice and normalize your data. You'll be amazed at how much easier things are to do with a good database design. In addition, Excel Pivot Tables are designed to take normalized data and to "pivot" it into summarized data in columns.

See: http://www.datamodel.org/NormalizationRules.html



- Jeff
Go to Top of Page

mahesh_bote
Constraint Violating Yak Guru

298 Posts

Posted - 2006-07-26 : 08:52:31
try it...

Select O.Id, C.Name From SysObjects As O, SysColumns As C
Where O.Id = C.Id And O.XType = 'U'
And (C.Name Like 'A%' Or C.Name Like 'B%' Or C.Name Like 'F%')

BMahesh
Go to Top of Page

mahesh_bote
Constraint Violating Yak Guru

298 Posts

Posted - 2006-07-26 : 08:54:56
if u want to retrive from specific table, u can provide table name also.

Select O.Id, C.Name From SysObjects As O, SysColumns As C
Where O.Id = C.Id And O.XType = 'U'
And (C.Name Like 'A%' Or C.Name Like 'B%' Or C.Name Like 'F%')
And O.Name = '<U'r Table Name>'


BMahesh
Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2006-07-26 : 13:00:50
Sysobjects = Evil

information_schema.columns = Your Friend

Help us help YOU!
Read this blog entry for more details: http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx

*need more coffee*
SELECT * FROM Users WHERE CLUE > 0
(0 row(s) affected)
Go to Top of Page
   

- Advertisement -