MSSQL BULK INSERT 插入文本内容到数据库

2021/5/10 19:25:40

本文主要是介绍MSSQL BULK INSERT 插入文本内容到数据库,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

CREATE TABLE [dbo].[ip](
 [ip_start] [varchar](50) NULL,
 [ip_end] [varchar](50) NULL,
 [ip_start_num] [bigint] NULL,
 [ip_end_num] [bigint] NULL,
 [continent] [varchar](50) NULL,
 [country] [varchar](50) NULL,
 [province] [varchar](50) NULL,
 [city] [varchar](50) NULL,
 [district] [varchar](50) NULL,
 [isp] [varchar](50) NULL,
 [area_code] [varchar](50) NULL,
 [country_english] [varchar](50) NULL,
 [country_code] [varchar](50) NULL,
 [longitude] [varchar](50) NULL,
 [latitude] [varchar](50) NULL
)

 

--导入数据库
BULK INSERT dbo.[ip]
FROM 'D:\IP数据库\ip.txt' 
WITH (
    CODEPAGE='65001',
    FIELDTERMINATOR = '|',
    ROWTERMINATOR = '\n'
)

 

ip.txt demo数据:
37.17.184.0|37.17.191.255|621918208|621920255|欧洲|英国||||||United Kingdom|GB|55.378051|-3.435973
37.17.192.0|37.17.207.255|621920256|621924351|亚洲|约旦||||||Jordan|JO|30.585164|36.238414
37.17.208.0|37.17.223.255|621924352|621928447|欧洲|荷兰||||||Netherlands|NL|52.132633|5.291266
61.134.201.0|61.134.211.255|1032243456|1032246271|亚洲|中国|山西|太原||联通|140100|China|CN|112.549248|37.857014
61.134.212.0|61.134.212.255|1032246272|1032246527|亚洲|中国|山西|太原|小店|联通|140105|China|CN|112.56878|37.73565
61.141.202.0|61.141.204.255|1032702464|1032703231|亚洲|中国|广东|深圳||电信|440300|China|CN|114.085947|22.547
61.141.205.0|61.141.205.255|1032703232|1032703487|亚洲|中国|广东|深圳|罗湖|电信|440303|China|CN|114.13116|22.54836
61.141.206.0|61.141.221.126|1032703488|1032707454|亚洲|中国|广东|深圳|宝安|电信|440306|China|CN|113.88311|22.55371
124.114.171.0|124.114.172.255|2087889664|2087890175|亚洲|中国|陕西|西安|雁塔|电信|610113|China|CN|108.94866|34.22245
183.202.48.0|183.202.59.255|3083481088|3083484159|亚洲|中国|山西|运城||移动|140800|China|CN|111.003957|35.022778
183.202.60.0|183.202.63.255|3083484160|3083485183|亚洲|中国|山西|长治||移动|140400|China|CN|113.113556|36.191112
183.202.64.0|183.202.75.255|3083485184|3083488255|亚洲|中国|山西|晋城||移动|140500|China|CN|112.851274|35.497553
223.221.212.0|223.221.255.255|3755856896|3755868159|亚洲|中国|青海|西宁||电信|630100|China|CN|101.778916|36.623178
223.222.0.0|223.222.255.255|3755868160|3755933695|亚洲|韩国||||||Korea, Republic of|KR|35.907757|127.766922
223.223.128.0|223.223.159.255|3755966464|3755974655|亚洲|印度||||||India|IN|20.593684|78.96288
223.223.168.0|223.223.175.255|3755976704|3755978751|亚洲|柬埔寨||||||Cambodia|KH|12.565679|104.990963
223.223.176.0|223.223.207.255|3755978752|3755986943|亚洲|中国|北京|北京|西城|电信|110102|China|CN|116.36003|39.9305
223.223.208.0|223.223.215.255|3755986944|3755988991|亚洲|日本||||||Japan|JP|36.204824|138.252924
223.223.216.0|223.223.219.255|3755988992|3755990015|亚洲|中国|香港||||810000|Hong Kong|HK|114.173355|22.320048
223.223.220.0|223.223.223.255|3755990016|3755991039|亚洲|新加坡||||||Singapore|SG|1.352083|103.819836

 

插入后结果:

 

 

 



这篇关于MSSQL BULK INSERT 插入文本内容到数据库的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程