transpose table

I have three tables

table 1: typeId, productid, TypeDescription, ExpDate

table 2: ProductId, ProductDescription, Size, Color

table 3, typeId, properyName, propertyValue

Give the typeId I have to return a recordset with 2 columns Name and value.

For table 1 and table 3 the Name column would contain the names of the tables columns and value column would contain the values.

For table 2 the Name column would contain the PropertyName and the value column would contain the PropertyValue column.

I want to generate a recordset with all the data for one typeId.

Is there an easy way to do all of this?

Thanks in advance


Malkie

[720 byte] By [malkie] at [2008-1-2]
# 1

As best as I can tell "TABLE 2" does not contain a "PROPERTY NAME" and also doesn't contain a "PROPERTY VALUE." That corresponds to table 3.

KentWaldropAp07 at 2007-9-13 > top of Msdn Tech,SQL Server,Transact-SQL...
# 2

I know. I am thinking that I would have to do one thing to table 1 and table 2 and then somehow union it to table 3's results.

I would want the end table to look like

name value

- -

typeId

productId

typeDescription

ExpDate

ProductId

ProductDescription

Size

Color

Table 3 Property Name 1

Table 3 Property Name 2

Table 3 Property Name 3

I am trying to pivot the first tables and then unioning it with the corresponding the information in table 3.

It would be best if I could do think dynamically so that if the tables were to change the stored procedure would not.

thanks

malkie at 2007-9-13 > top of Msdn Tech,SQL Server,Transact-SQL...

SQL Server

Site Classified