SELECT
ar.ArticleID,
ar.Title,
STUFF( (SELECT ',' + ad.Name
FROM TBL_ARTICLEBET as ab
JOIN TBL_ADDED as ad
on ad.AddedID = ab.AddedID
WHERE ab.ArticleID = ar.ArticleID
FOR XML PATH(''), TYPE).value('.', 'varchar(max)')
,1, 1, '')
FROM TBL_ARTICLE as ar
ALTER Procedure [dbo].[sp_Addes_Article_SelectAllTbl]
@ArticleID int
As
Begin
select * from Tbl_Article inner join Tbl_Articlebet on Tbl_Article.ArticleID =Tbl_Articlebet.ArticleID
inner join Tbl_Addes_Article on Tbl_Articlebet. AddedID=Tbl_Addes_Article. AddedID
where Tbl_Article.ArticleID=@ArticleID
End
update ar
set AddedNames = STUFF( (SELECT ',' + ad.Name
FROM TBL_ARTICLEBET as ab
JOIN TBL_ADDED as ad
on ad.AddedID = ab.AddedID
WHERE ab.ArticleID = ar.ArticleID
FOR XML PATH(''), TYPE).value('.', 'varchar(max)')
,1, 1, '')
FROM TBL_ARTICLE as ar;
select * from TBL_ARTICLE;
Please make sure your datais exsit in persian in your table , use nvarchar(max) as datatype in your query and try again.
update ar
set AddedNames = STUFF( (SELECT ',' + ad.Name
FROM TBL_ARTICLEBET as ab
JOIN TBL_ADDED as ad
on ad.AddedID = ab.AddedID
WHERE ab.ArticleID = ar.ArticleID
FOR XML PATH(''), TYPE).value('.', 'nvarchar(max)')
,1, 1, '')
FROM TBL_ARTICLE as ar;
select * from TBL_ARTICLE;
Best Regards,
Please mark the replies as answers if they help or unmark if not.
Feedback to us
Please make sure your datais exsit in persian in your table , use nvarchar(max) as datatype in your query and try again.
update ar
set AddedNames = STUFF( (SELECT ',' + ad.Name
FROM TBL_ARTICLEBET as ab
JOIN TBL_ADDED as ad
on ad.AddedID = ab.AddedID
WHERE ab.ArticleID = ar.ArticleID
FOR XML PATH(''), TYPE).value('.', 'nvarchar(max)')
,1, 1, '')
FROM TBL_ARTICLE as ar;
select * from TBL_ARTICLE;
Best Regards,
Thanks.
IF my answer is correct then please MARK my answer
hiden
Member
69 Points
96 Posts
Replace values a row use other row table
Jan 09, 2013 02:18 PM|LINK
hi to all.
i have three table that i want copy many row this tables in a row One of the table.
this cshema my tables and What I want.
i want replace row Name as TBL_ADDED to row AddedNames as TBL_ARTICLE.
imobsuz
Participant
1278 Points
195 Posts
Re: Replace values a row use other row table
Jan 09, 2013 03:17 PM|LINK
Hi,
Try:
SELECT ar.ArticleID, ar.Title, STUFF( (SELECT ',' + ad.Name FROM TBL_ARTICLEBET as ab JOIN TBL_ADDED as ad on ad.AddedID = ab.AddedID WHERE ab.ArticleID = ar.ArticleID FOR XML PATH(''), TYPE).value('.', 'varchar(max)') ,1, 1, '') FROM TBL_ARTICLE as arHope this help.
hiden
Member
69 Points
96 Posts
Re: Replace values a row use other row table
Jan 09, 2013 03:36 PM|LINK
thanks imobsuz .but select not my Problem.
i use this code for select:
after run this wuery show all row three table :
[addedID],[ArticleID],[Name],[Picture],[DateBirthday],[Education],[Point],[EmailAddress],[Countarticle],[ArticleID],[Title],[Preview],[Body],[AddedNames],[Keywords],[PDFFiles],[AddedDate],[AddedIp],[CountViewed],[Status],[ArticlebetID],[addedID],[ArticleID]
i want replace (update) row Name as TBL_ADDED to row AddedNames as TBL_ARTICLE and select all row TBL_ARTICLE.
<div></div>imobsuz
Participant
1278 Points
195 Posts
Re: Replace values a row use other row table
Jan 09, 2013 04:04 PM|LINK
Try something like this:
update ar set AddedNames = STUFF( (SELECT ',' + ad.Name FROM TBL_ARTICLEBET as ab JOIN TBL_ADDED as ad on ad.AddedID = ab.AddedID WHERE ab.ArticleID = ar.ArticleID FOR XML PATH(''), TYPE).value('.', 'varchar(max)') ,1, 1, '') FROM TBL_ARTICLE as ar; select * from TBL_ARTICLE;Hope this help.
hiden
Member
69 Points
96 Posts
Re: Replace values a row use other row table
Jan 09, 2013 06:07 PM|LINK
Thanks imobsuz.
why my value rows is ?????????.
i values used is persian.(arabic word)
Chen Yu - MS...
All-Star
21600 Points
2493 Posts
Microsoft
Re: Replace values a row use other row table
Jan 11, 2013 05:21 AM|LINK
HI,
Please make sure your datais exsit in persian in your table , use nvarchar(max) as datatype in your query and try again.
update ar set AddedNames = STUFF( (SELECT ',' + ad.Name FROM TBL_ARTICLEBET as ab JOIN TBL_ADDED as ad on ad.AddedID = ab.AddedID WHERE ab.ArticleID = ar.ArticleID FOR XML PATH(''), TYPE).value('.', 'nvarchar(max)') ,1, 1, '') FROM TBL_ARTICLE as ar; select * from TBL_ARTICLE;Best Regards,
Feedback to us
Develop and promote your apps in Windows Store
hiden
Member
69 Points
96 Posts
Re: Replace values a row use other row table
Jan 12, 2013 09:47 PM|LINK
T
Thanks.