| | |
Importing xml into sql server 2008
Please support our MS SQL advertiser: Intel Parallel Studio Home
Thread Solved |
Hi,
I need a little help importing an XML file into sqlserver 2008. I followed this example
http://www.sql-server-performance.co...r_2008_p1.aspx
(make sure you goto the rest of the pages in the article!) , generated the schema etc., but I can't get the import
to do what I need. I was able to add the DataConversion on my own but I can't seem to figure out how to get both ID
fields in the middle table.
I made a simplified version. For this example I have 3 tables. Books, BookAuthors, Authors.
Books Table (bookID, bookTitle, bookNumPages)
BookAuthors Table (bookID, authorID)
Authors (authorID, authorName)
After the Import the tables should look like this
Books
79, Some Good Book, 300
112, Another Book, 350
BookAuthors
79, 200
79, 205
79, 215
112, 200
Authors
200, First Author
205, Second Author
215, Third Author
The Problem I'm having is getting the BookID and AuthorID into the BookAuthors Table. I'm just wondering if there
is an easy way to set this up to Import or if I'm going to have to code it line by line.
I need a little help importing an XML file into sqlserver 2008. I followed this example
http://www.sql-server-performance.co...r_2008_p1.aspx
(make sure you goto the rest of the pages in the article!) , generated the schema etc., but I can't get the import
to do what I need. I was able to add the DataConversion on my own but I can't seem to figure out how to get both ID
fields in the middle table.
I made a simplified version. For this example I have 3 tables. Books, BookAuthors, Authors.
Books Table (bookID, bookTitle, bookNumPages)
BookAuthors Table (bookID, authorID)
Authors (authorID, authorName)
After the Import the tables should look like this
Books
79, Some Good Book, 300
112, Another Book, 350
BookAuthors
79, 200
79, 205
79, 215
112, 200
Authors
200, First Author
205, Second Author
215, Third Author
The Problem I'm having is getting the BookID and AuthorID into the BookAuthors Table. I'm just wondering if there
is an easy way to set this up to Import or if I'm going to have to code it line by line.
MS SQL Syntax (Toggle Plain Text)
<?xml version="1.0" encoding="UTF-8"?> <result> <books> <book> <bookID>79</bookID> <bookTitle>Some Good Book</bookTitle> <bookNumPages>300</bookNumPages> <authors> <author> <authorID>200</authorID> </author> <author> <authorID>205</authorID> </author> <author> <authorID>215</authorID> </author> </authors> </book> <book> <bookID>112</bookID> <bookTitle>Another Book</bookTitle> <bookNumPages>350</bookNumPages> <authors> <author> <authorID>200</authorID> </author> </authors> </book> </books> <authors> <author> <authorID>200</authorID> <authorName>First Author</authorName> </author> <author> <authorID>205</authorID> <authorName>Second Author</authorName> </author> <author> <authorID>215</authorID> <authorName>Third Author</authorName> </author> </authors> </result>
1
#2 31 Days Ago
4 days and no answers so I just did it myself and ending up making a blog incase someone else needs to do the same thing. You can find the solution here
http://dvprez.blogspot.com/2009/10/i...rver-2008.html
http://dvprez.blogspot.com/2009/10/i...rver-2008.html
![]() |
Similar Threads
- sql server 2008 (MS SQL)
- Problem with SQL Server 2008 installation (VB.NET)
- How to import ".mdb" files into SQL Server 2008? (MS SQL)
- Can SQL Server 2008 access Northwind or Pubs databases? (MS SQL)
- I can’t install SQL Server 2008 Express with Advanced Services - Help! (MS SQL)
- News Story: Which SQL Server 2008 edition is right for you? (MS SQL)
- SQL Server DBA - " Hot " (Software Development Job Offers)
- SQL Server DBA (Software Development Job Offers)
Other Threads in the MS SQL Forum
- Previous Thread: SSIS Permission Problem
- Next Thread: Connection Strings to network.
| Thread Tools | Search this Thread |





