在变量周围添加引号

Add quotes around variable(在变量周围添加引号)
本文介绍了在变量周围添加引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从 SQL 导出数据并导入到 SAS.地址字段的字符串中间有,".我尝试使用 CSV 和制表符分隔,但每次 SAS 都会因,"而拆分地址字段.

I need to export data from SQL and import into SAS. The address field has ',' in the middle of the string. I tried using CSV and tab delimited, but each time SAS breaks up the address field due to the ','.

我尝试使用另一个问题的代码将逗号替换为空格,但没有用:

I tried replacing the comma with a space using code from another question, but it did not work:

 update #temp2
 set STREETADDRESS_e = REPLACE(STREETADDRESS_e ,","," ")

我想如果我把地址字符串放在引号中,这会解决问题,但我的代码不起作用:

I thought if I put the address string in quotes, this would solve the problem, but my code is not working:

 update #temp2
 set STREETADDRESS_e = ("'" + STREETADDRESS_e + "'")

这似乎是一个非常普遍的问题,但我还没有找到任何可行的解决方案...

This seems like it must be a very common problem but I have not found any working solutions...

推荐答案

如果你想用单引号将字符串括起来,你必须像这样对它们进行转义:

If you want to surround the string with single-quotes you have to escape them like this:

update #temp2 set STREETADDRESS_e = ('''' + STREETADDRESS_e + '''')

update #temp2 set STREETADDRESS_e = QUOTENAME(STREETADDRESS_e,'''')

或者如果你想要双引号

update #temp2 set STREETADDRESS_e = QUOTENAME(STREETADDRESS_e,'"')

这篇关于在变量周围添加引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Execute complex raw SQL query in EF6(在EF6中执行复杂的原始SQL查询)
Hibernate reactive No Vert.x context active in aws rds(AWS RDS中的休眠反应性非Vert.x上下文处于活动状态)
Bulk insert with mysql2 and NodeJs throws 500(使用mysql2和NodeJS的大容量插入抛出500)
Flask + PyMySQL giving error no attribute #39;settimeout#39;(FlASK+PyMySQL给出错误,没有属性#39;setTimeout#39;)
auto_increment column for a group of rows?(一组行的AUTO_INCREMENT列?)
Sort by ID DESC(按ID代码排序)