sql 查询列 进行 拼接 单引号 逗号_xml path excel

方法一:

		SELECT
			[id] = stuff(
				(
					SELECT distinct
						',''' + user.id + ''''
					FROM
						t_user user
					WHERE 1=1
						 FOR xml path ('')
				),
				1,
				1,
				''
			)

result:

'17797607','21000395','21804864','23607889','24832497'
SELECT 
''+'第' + convert(varchar,cp.xh) + '次:'+cp.testDate+''
FROM t_cp cp WHERE 
isDelete=0   order by cp.xh FOR xml path ('')

方法二:

将查询到的记录,使用Excel 拼接

="'"&A1&"',"

sql

SELECT  (''''+  name+''',') FROM t_user where 1=1

Oracle_字段拼接_逗号_单引号

你可能感兴趣的:(SqlServer,util功能实现,database,Excel)