游泳的鱼进来帮我看看 !
这个SQL是我从CSDN上看到的 我改了改想用到我的项目里面可是那个双引号无法在C#里面拼成字符串 要是用原样输出 拼凑起来的SQL到查询分析器里面查询就不是我要的结果了 用@也不行 你看看有什么好的办法没有
SELECT *FROM
(SELECT DISTINCT authorid FROM blog_log where authorid=1)
A
OUTER APPLY
(SELECT [logid]= STUFF(REPLACE(REPLACE(
(SELECT logid FROM blog_log N WHERE authorid = A.authorid FOR XML AUTO),
' <N logid= " ', ', '), ' "/> ', ' '), 1, 1, ' '))N
------解决方案--------------------creat PROCEDURE [dbo].[sp_Together]
@Value int
AS
BEGIN
SELECT logid FROM
(SELECT DISTINCT authorid FROM blog_log where authorid=@Value)
A
OUTER APPLY
(SELECT [logid]= STUFF(REPLACE(REPLACE(
(SELECT logid FROM blog_log N WHERE authorid = A.authorid FOR XML AUTO),
' <N logid= " ', ', '), ' "/> ', ' '), 1, 1, ' '))N
END