Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在sql server中复制到记事本时如何断开字段中的文本_Sql_Sql Server_Sql Server 2008 - Fatal编程技术网

在sql server中复制到记事本时如何断开字段中的文本

在sql server中复制到记事本时如何断开字段中的文本,sql,sql-server,sql-server-2008,Sql,Sql Server,Sql Server 2008,我在SQLServer中使用char(13)和char(10)作为中断文本 我想当复制文本文件的内容放在记事本顶部时,文本处于中断状态。 我使用以下代码换行: declare @result varchar(30)='this is some'+ char(13)+char(10)+'text' 但当我将文本复制到记事本时,所有文本都显示在一行中。 我该怎么做 我在谷歌上搜索过,但找不到任何类似的答案。它必须工作: 只要试试这个(只使用char(13)或char(10)中的一个也会给出相同的输

我在SQLServer中使用char(13)和char(10)作为中断文本

我想当复制文本文件的内容放在记事本顶部时,文本处于中断状态。 我使用以下代码换行:

declare @result varchar(30)='this is some'+ char(13)+char(10)+'text'
但当我将文本复制到记事本时,所有文本都显示在一行中。 我该怎么做

我在谷歌上搜索过,但找不到任何类似的答案。

它必须工作:

只要试试这个(只使用
char(13)
char(10)
中的一个也会给出相同的输出)

输出:(从我的窗口复制了精确的输出)

但要将结果发送到记事本(windows),请不要从management studio中显示的网格中复制/通过,请使用
xp\u cmdshell
,如下所示:

master..xp_cmdshell 'bcp "SELECT ''this is some''+char(13)+char(10)+''text''" queryout C:\myText.txt -t, -c -Slocalhost -T'
确切内容:

注意:您可能需要启用xp\u cmdshell:

EXEC sp_configure 'show advanced options', 1
GO
RECONFIGURE
GO
EXEC sp_configure 'xp_cmdshell', 1
GO
RECONFIGURE
GO

你只试过其中一个吗!??不是两个都在一起。我的意思是一次也可以尝试使用char(10)或char(13)而不是同时使用
char(13)
和一次
char(10)
进行时间检查。但是我没有得到任何结果。如何从静态文本中使用Veriable。我想用像
@txt
master..xp_cmdshell 'bcp "SELECT ''this is some''+char(13)+char(10)+''text''" queryout C:\myText.txt -t, -c -Slocalhost -T'
this is some
text
EXEC sp_configure 'show advanced options', 1
GO
RECONFIGURE
GO
EXEC sp_configure 'xp_cmdshell', 1
GO
RECONFIGURE
GO