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)
 Issue with update statement

Author  Topic 

atlachar123456
Starting Member

33 Posts

Posted - 2011-11-08 : 09:40:45
Hi,
I have a requirement to dispaly product family
for that i have added one column with product family name in temporary table #rpt1 and we have product id
and created a temporary table #productdetails with two columns
pt_sp_type_c its a productfamily and pt_sb_type_c and its a productid

create table #rpt1
(
productId INT NULL,
productfamily varchar(20) null
)

create table #productdetails
(
pt_sp_type_c
pb_sp_type_c
)

--inserted some data into productdetails

INSERT INTO #ProductDetails
SELECT DISTINCT pt_sp_type_c, pt_sb_type_c
FROM product..p_type_p_type
WHERE p_type_use_sp_c = 'RPCDB'
AND p_type_use_sb_c = 'TRD'
AND pt_rel_stat_c = 'ACTIVE'

and inserted null where ever its insert into #rpt1

and last updated the #rpt1
UPDATE #rpt1
SET Productfamily = PD.pt_sp_type_c
FROM #rpt1 s,
#ProductDetails PD
WHERE PD.pt_sb_type_c = CAST(s.productId AS VARCHAR(10))

actually in the req doc for the producttype column there is some data but when i execute teh above query for me its showing null
when i execute the snippet of code which is in insert into productdetails i got the data for that two columns i think there is some mistake in my
update statement,can we use update with righ too left outer joins..can any one come with proper solution.

atlaaaaaaaa

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-08 : 10:15:04
sorry reqmnt not clear. please post some data and explain your problem

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -