问题描述
希望你们一切顺利.
我需要将 xml 源从网站导入到我的 sql server 数据库.我对 xml 不太了解.
i need to import an xml-feed from a website to my sql server database. i don't know much about xml.
feed 结构有点复杂.这是该文件的示例:
the feed structure is an bit complex. here is the sample of that file:
1279519582927 4103839 58629754 2010-07-19 21:30 174087393 tennis abc r. ram 4303 4303 visiting k. beck 4304 4304 home 0 game 2010-07-19 21:30 i open 250 1500 250 135 -146 0 game 2010-07-19 21:30 i open 250 250 250 2 101 -2 -118 22.5 -108 -108 1 1st set 2010-07-19 21:30 i open 5000 250 5000 114 -133
能否请您帮帮我,我该如何将数据从该提要加载到 sql server.
can you please help me out, how can i approach to load the data from that feed to sql server.
另请询问我是否需要了解此场景的任何其他详细信息.等待您的友好回复.
please also ask me if any other details needed to understand this scenario. awaiting your kind response.
谢谢,普拉桑特
推荐答案
如果您的 xml 格式良好,您可以将其存储在 xml 类型变量中.然后你可以使用 xpath 从中读取字段:
if your xml is wel-formed, you can store it in an xml type variable. then you can use xpath to read fields from it:
declare @xml xml set @xml = '1279519582927 ... ' select @xml.value('(line_feed/events/event/sporttype)[1]', 'varchar(8000)')
这将打印tennis.