sql-server - SQL Server 存储过程 : Read data from URL text file

标签 sql-server http stored-procedures text text-files

我是 SQL Server 的新手,想编写一个从该 URL 获取数据的存储过程:

https://www.google.com/basepages/producttype/taxonomy.en-US.txt

看起来如下:

  # Google_Product_Taxonomy_Version: 2015-02-19
    Animals & Pet Supplies
    Animals & Pet Supplies > Live Animals
    Animals & Pet Supplies > Pet Supplies
    Animals & Pet Supplies > Pet Supplies > Bird Supplies
    Animals & Pet Supplies > Pet Supplies > Bird Supplies > Bird Cage Accessories
    Animals & Pet Supplies > Pet Supplies > Bird Supplies > Bird Cage Accessories > Bird Cage Bird Baths

并将其插入到表中:

TABLEA (id, text) 

其中 id 是自动生成的。

我知道如何进行插入部分,但是我不知道如何从指向文本文件的外部 URL 读取和解析存储过程中的数据。我怀疑它可以以某种方式加载到具有单列的“临时表”中。

不知道这是否可能,或者我需要在 C# 中处理“读取”部分,寻找一些指导....

最佳答案

你可以在你的服务器上使用 xp_cmdshell 命令吗?如果使用,可以先用shell命令将文件下载到本地

EXEC xp_cmdshell 'bitsadmin /transfer wcb /priority high https://www.google.com/basepages/producttype/taxonomy.en-US.txt f:\test.txt' 

关于sql-server - SQL Server 存储过程 : Read data from URL text file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45286727/

相关文章:

SQL Server 存储过程参数类型转换

sql-server - 您是否生成数据字典?

sql - 如何从第一个表中选择第二个表中不可用的时间?

java - JSoup 抛出 IO 异常 : Too many redirects occurred trying to load URL

php - 为多个插入和更改表查询创建存储过程

sql-server - 存储过程中 IN 运算符导致数据类型 nvarchar 转换为 bigint 时出错

java - Findbugs 说 "HTTP parameter directly written to HTTP header"

java - Android:AndroidHttpClient - 如何设置超时?

java - 使用不同的服务器或机器将记录从一个数据库同步到另一个数据库

SQL Server - 在存储过程中选择 * 与选择列