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
 General SQL Server Forums
 New to SQL Server Programming
 SQL help

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-01-18 : 09:00:56
Andrew writes "I am a relative SQL novice.

I am working on an application where I have a number of rows in a table, say table1, that need to be represented on a single row. The number of source rows is variable from 1 to 50. What I need to learn is how do I form the proceedure to form the data in the layout I need?

Basically the source table looks like this

Catalog
Page
Seq
Barcode
Desc
Pic

What I need is for all the barcodes related to a single page to be pulled and presented so I can place then all at the same time. I have thought about writing a VB program to collapse all the records into a single record by page number,yeilding a records with the following layout but I thought there has to be a way to pull this off in SQL.

Catalog
Page
[Barcode Seq1]
[Desc 1]
[Pic 1]
[Barcode Seq2]
[Desc 2]
[Pic 2]
....
....
...
and so on until I get to the end of each unique page

Is this anything that you can lend any advice for?"

Norwich
Posting Yak Master

158 Posts

Posted - 2006-01-18 : 12:16:59
Please elaborate a bit more

If you want your computer to be faster then throw it out of the window.
Go to Top of Page

druer
Constraint Violating Yak Guru

314 Posts

Posted - 2006-01-18 : 14:29:21
A couple of ways to do it. One way would be with brute force.

Select (Select name from table1 where criteria = true) as Field1, (Select name from table1 where other criteria = true) as Field2 etc.

Not knowing your Table1 structure, or what you mean by "Variable" not much more I can do for you.

Go to Top of Page
   

- Advertisement -