• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

在 SQL 输出插入双引号

用户头像
it1352
帮助4

问题说明

例如,在我运行查询并查看输出之后

After I run a query and view the output, for example

select * from People

我的输出如下

First   Last      Email
Ray     Smith     raysmith@whatever.itis

如何导出这些数据,使其看起来如下所示?

How would I export this data so that it looks as follows?

"Ray","Smith","raysmith@whatever.itis"

或者有没有办法在 SQL 中执行此操作以修改记录以包含引号?

Or is there a way to do this within SQL to modify records to contain quotes?

因为当您导出时,它无论如何都会包含逗号,对吗?

Because when you export, it's going to include the commas anyway, right?

正确答案

#1

如果您感兴趣的列不超过 128 个字符,您可以使用 QUOTENAME 函数.请注意这一点,因为任何超过 128 个字符的内容都将返回 NULL.

If the columns you're interested in are 128 characters or less, you could use the QUOTENAME function. Be careful with this as anything over 128 characters will return NULL.

SELECT QUOTENAME(First, '"'), QUOTENAME(Last, '"'), QUOTENAME(Email, '"')
    FROM People

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /reply/detail/tangibhec
系列文章
更多 icon
同类精品
更多 icon
继续加载