从加载到数据库的 CSV 数据中快速删除单引号

发布于 2024-11-05 12:41:20 字数 384 浏览 0 评论 0原文

我有一个由从外部源加载的 CSV 文件构建的数据库。由于某种原因,许多表中的 ID 号被加载到用单引号括起来的 CSV/数据库中 - 这是一个示例行:

 "'010010'","MARSHALL MEDICAL CENTER NORTH","8000 ALABAMA HIGHWAY 69","","","GUNTERSVILLE","AL","35976","MARSHALL","2565718000","Acute Care Hospitals","Government - Hospital District or Authority","Yes"

是否有任何 SQL 我可以在已经建立的数据库上运行来删除这些单引号,或者执行以下操作:我必须解析每个 CSV 文件并重新导入吗?

I have a database built from CSV files loaded from an external source. For some reason, an ID number in many of the tables is loaded into the CSV / database encased in single quotes - here's a sample line:

 "'010010'","MARSHALL MEDICAL CENTER NORTH","8000 ALABAMA HIGHWAY 69","","","GUNTERSVILLE","AL","35976","MARSHALL","2565718000","Acute Care Hospitals","Government - Hospital District or Authority","Yes"

Is there any SQL I can run on the already-established database to strip these single quotes, or do I have to parse every CSV file and re-import?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

执手闯天涯 2024-11-12 12:41:20

我相信以下方法可以做到这一点(首先测试它):

UPDATE U
SET YourID = REPLACE(YourID, '''', '')
FROM MyTable AS U
WHERE YourID LIKE '''%'''

如果它工作正常,请在生产中运行之前进行完整备份。

I believe the following would do it (test it first):

UPDATE U
SET YourID = REPLACE(YourID, '''', '')
FROM MyTable AS U
WHERE YourID LIKE '''%'''

If it works right, do a full backup before running it in production.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文