我正在尝试将Vanilla论坛导出的数据导入SQL Server,以便我可以编写某种脚本将其导入YAF.NET。我尝试过使用集成服务项目和SQL Server导入向导。论坛和用户最终都去了,但主题表给我带来了麻烦。问题是记录的分离,我不能用平面文件数据源正确分割它们。
例如:
DiscussionID,CategoryID,InsertUserID,UpdateUserID,Name,Body,Format,CountComments,CountViews,Closed,Announce,Sink,DateInserted,DateUpdated,InsertIPAddress,UpdateIPAddress,DateLastComment,Score
1,2,2,0,"Welcome","","Html",1,1,0,0,0,"2005-11-22 20:36:00","2005-11-22 20:36:00",\N,\N,"2005-11-22 20:36:00",\N
13,5,5,0,"Custom Feilds","Hi Echilon\,\
\
I've been fiddling with iZeit Calendar a bit (though I haven't published anything\, as that would be inapropriate without your permission) and I have tried\, without success\, to add extra fields to both the input form and the calendar output.\
\
So far I've added the extra columns to the database\, attempted to edit the multiple queries in functions.php -> addevent() function with little success.\
\
I was wondering if you could help me out a bit in better understanding the flow of data from input fields to database query.\
\
Once I get the data into the database\, I shouldn't see any future problems of displaying it.\
\
I would also like to note that you've done a fantastic job with this software!\
\
-Ax","Html",4,1830,0,0,0,"2006-02-23 00:14:43","2006-02-24 18:57:53",\N,\N,"2006-02-24 18:57:53",\N
3,4,2,0,"[Wallpaper] Aeon Genesis","<a target=\"_blank\" href=\"http://www.deviantart.com/deviation/24402244/\"></a><img src=\"http://mi6.nu/aeon_small.jpg\" border=\"0\" />\
<a target=\"_blank\" href=\"http://www.deviantart.com/deviation/24402244/\">Full Size - 1600x1200</a>\
\
I made this in 2004\, it's an edited photo of the view from my window at sunset.","Html",1,1052,0,0,0,"2005-11-23 09:46:29","2005-11-23 09:46:29",\N,\N,"2005-11-23 09:46:29",\N
4,7,2,0,"Moodsig","This is a script which lets you pick a mood from a control panel\, then have it display that mood in a sig\, along with a random quote from a database. It's not quite finished yet\, but it should be released sometime this week. I just have to track down the guys who made the smileys for permission. It's a bit buggy at the minute\, but it should be working in a few days.\
\
At the minute\, you need PHP and a MySQL database\, but I might release a version which only needs php and a text file if there's demand for it.\
\
This is the control panel\, which controls the sig I'm using now.\
<a target=\"_blank\" href=\"http://mi6.nu/moodsig_0.8.jpg\"></a><img src=\"http://mi6.nu/moodsig_0.8_thumb.jpg\" border=\"0\" />","Html",1,1100,0,0,0,"2005-11-23 15:38:56","2005-11-23 15:38:56",\N,\N,"2005-11-23 15:38:56",\N
5,4,2,0,"Dynasig 1.0","Dynasig lets you set your current mood with a web based control panel\, then display it aswell as a random quote in a signature which you can use on a forum.\
\
<b>Installation</b>\
You'll need a webserver with PHP and MySQL. In the future\, I might release a version that doesn't need MySQL\, but for now\, you have to have it. \
\
1) Set up a database on ...
在这种情况下,新记录从这些行开始:
3,4,2,0,"[Wallpaper] Aeon Genesis","<a ta
4,7,2,0,"Moodsig","
5,4,2,0,"Dynasig 1.0","Dynasig l
我如何将其导入SQL服务器?
答案 0 :(得分:0)
如果您只处理特定分隔符(例如逗号),则可以使用BULK INSERT
任务(请参阅:http://blog.sqlauthority.com/2008/02/06/sql-server-import-csv-file-into-sql-server-using-bulk-insert-load-comma-delimited-file-into-sql-server/)。
BULK
INSERT ForumTable
FROM 'c:\ForumFlatFile.txt'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)
GO
如果你想导入某些标签和声明(我无法告诉OP,抱歉),我建议使用功能。例如,根据论坛帖子的导出方式,构建可以解析标签之间某些值的函数(例如,一个可以解析A HREF
个标签的函数)。有时论坛帖子可以以某些模式结束和结束,并且一个函数可以“识别”这些开始和结束标记,并在值之间抓取。