alter function yazarkitap(
@yazarID int)
returns nchar(100)
as
begin
declare @kitaplar nchar(500)
select @yazarID=y_id from yazar
select (STUFF((select','+kitap_adi from Kitap where @yazarID=y_id FOR XML PATH('')
),1,2,''))as kitapadi
end
我正在尝试yazar_id
并显示所有kitap_adi
在一行中都有相同的yazar_id
。我搜索了合并功能,但我做不到。
答案 0 :(得分:0)
你的写作有点不对劲。您可以按如下方式更改它。您可能会再次收到错误。我建议你删除它并重新创建它。
ALTER FUNCTION yazarkitap
(
@yazarID INT
)
RETURNS NVARCHAR(MAX)
AS
BEGIN
DECLARE @kitaplar NVARCHAR(MAX)
SELECT @kitaplar = STUFF((
SELECT ',' + kitap_adi
FROM Kitap
WHERE
y_id = @yazarID
FOR XML PATH('')
), 1, 1, '')
RETURN @kitaplar
END