本文介绍了怎么写东西功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个查询,但没有解决错误部分..



这里我提到了我的查询..



I am trying to write one query but did't get to solve the error part..

here i mentioned my query..

SELECT DISTINCT empcode,
  STUFF(
  (
    SELECT distinct ',' + Cast(Day([Date]) AS varchar)
    FROM dcr p1
    WHERE p.empcode= p1.empcode
    FOR XML PATH(''), TYPE
  )
  --.value('.', 'NVARCHAR(MAX)')
  ,1,1,'') as DateConcate
FROM dcr p;





但收到错误..





but getting error..

Msg 8116, Level 16, State 1, Line 1<br />
Argument data type xml is invalid for argument 1 of stuff function.

推荐答案

SELECT DISTINCT empcode, STUFF((
    SELECT distinct ',' + Cast(Day([Date]) AS varchar(20))
    FROM dcr p1
    WHERE p.empcode= p1.empcode
    FOR XML PATH('')),1,1,'') as DateConcate
FROM dcr p;


这篇关于怎么写东西功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 12:31