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)
 Is there a better way of doing this ?

Author  Topic 

sp_wiz
Yak Posting Veteran

55 Posts

Posted - 2001-06-30 : 15:32:34
Please can some one suggest a better way of achieving this..

I have 2 tables 1 is a products table and the other contains a list of product makes.

The product table holds a comma delimited string with the id's of the makes table
ie '1,2,3'

Which in the makes table is
1 = sony
2 = phillips
3 = what ever

Obviously i want to display the makes names that cover that product details

The sp i am using works but i'm sure there must be a better solution.

BEGIN

declare @make varchar(50)
select @make = make from diy_products where product_id = @product_id
declare @cmd varchar(300)
declare 'make_names varchar(200)
set @cmd = 'select @make_names = make from diy_makes where id in ('+@make+')'

Select *,@make_names from diy-products where product_id = @productID

END

Robp



   

- Advertisement -