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
 need to update script

Author  Topic 

rudba
Constraint Violating Yak Guru

415 Posts

Posted - 2009-05-28 : 15:19:35
Hello everybody,
I have a table with ID,PID,OID,FValue and AllValue fields.
I need to update AllValue field where PID=PID and OID=0.
How do i add FValue's data into Allvalue if there are PID=PID

declare @tbl1 table
(ID INT,
PID INT,
OID INT,
FValue varchar(50),
AllValue varchar(255)

)

INSERT INTO @tbl1
SELECT 1, 101,0,'Aa',NULL

INSERT INTO @tbl1
SELECT 2, 101,1,'Ab',NULL

INSERT INTO @tbl1
SELECT 3, 101,2,'Abc',NULL

INSERT INTO @tbl1
SELECT 4, 104,0,'Xy',NULL

INSERT INTO @tbl1
SELECT 5, 104,1,'MN',NULL

My output looks like this
select ID, AllValue from @tbl1

1 Aa;Ab;Ac
2 NULL
3 NULL
4 Xy;MN
5 NULL

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-05-28 : 16:11:25
See http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=81254


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -