Hey, Lets say we have a query which generates list of city names as output.
嘿,让我们说我们有一个查询,它生成城市名称列表作为输出。
1.India 2.America
Now if we want to make this data look like a CSV i.e.
现在,如果我们想让这些数据看起来像一个CSV,即
India,America
then how we will generate it in MS SQL 2000
然后我们将如何在MS SQL 2000中生成它
In 2005I have done this using XM Path
在2005年,我使用XM Path完成了这项工作
1 个解决方案
#1
assuming your query is in a table called Table with a field called Nation:
假设您的查询位于名为Table的表中,其中包含一个名为Nation的字段:
DECLARE @rval varchar(5000)
SELECT @rval = COALESCE(@rval + ',','') + Nation FROM Table
SELECT @rval
If you have India, and America in it...it will return: India,America
如果你有印度和美国......它将回归:印度,美国
#1
assuming your query is in a table called Table with a field called Nation:
假设您的查询位于名为Table的表中,其中包含一个名为Nation的字段:
DECLARE @rval varchar(5000)
SELECT @rval = COALESCE(@rval + ',','') + Nation FROM Table
SELECT @rval
If you have India, and America in it...it will return: India,America
如果你有印度和美国......它将回归:印度,美国