473,657 Members | 2,435 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SQL Bulk load - creating Schema file

Hi,

I want to back up my data in some table in SQL server and import it back
using Bulk Load of SQL server 2K.

I can use the following code to backup the data in XML

dataset.WriteXm l(@"C:\Data.xml ");
dataset.WriteXm lSchema(@"C:\Sc hema1.xml");

and following code to bulk import the same data

SQLXMLBULKLOADL ib.SQLXMLBulkLo ad3 x = new
SQLXMLBULKLOADL ib.SQLXMLBulkLo ad3Class();
x.ConnectionStr ing
="PROVIDER=SQLO LEDB.1;SERVER=l ocalhost;UID=sa ;PWD=;DATABASE= demo01";
x.XMLFragment = true;
x.ErrorLogFile = @"c:\error.txt" ;
x.SchemaGen = true;
x.SGDropTables = true;
x.Execute(@"C:\ Schema.xml",@"C :\data.xml");

this do not work, but do not thoow any error either, when I looked
closely... the format of the schema file is incorrect, if I create a correct
formate maually it works.

Does some one know how to generate schema file in correct format? using
..Net.

Regards
Kiran
Nov 16 '05 #1
3 8086
This post was almost 2 weeks ago now, so I hope you got the answer by now. If not, here are my 2 bits.

As I understand it, SQLXMLBulkLoad. SchemaGen refers to creating the SQL tables into which the data will go in the BulkLoad, not to creating the schema (xsd). It takes the place of the CREATE TABLE (...) SQL command. So if true, the tables are created if they don't already exist (if they do, the data goes into the existing tables).

"Kiran" wrote:
Hi,

I want to back up my data in some table in SQL server and import it back
using Bulk Load of SQL server 2K.

I can use the following code to backup the data in XML

dataset.WriteXm l(@"C:\Data.xml ");
dataset.WriteXm lSchema(@"C:\Sc hema1.xml");

and following code to bulk import the same data

SQLXMLBULKLOADL ib.SQLXMLBulkLo ad3 x = new
SQLXMLBULKLOADL ib.SQLXMLBulkLo ad3Class();
x.ConnectionStr ing
="PROVIDER=SQLO LEDB.1;SERVER=l ocalhost;UID=sa ;PWD=;DATABASE= demo01";
x.XMLFragment = true;
x.ErrorLogFile = @"c:\error.txt" ;
x.SchemaGen = true;
x.SGDropTables = true;
x.Execute(@"C:\ Schema.xml",@"C :\data.xml");

this do not work, but do not thoow any error either, when I looked
closely... the format of the schema file is incorrect, if I create a correct
formate maually it works.

Does some one know how to generate schema file in correct format? using
..Net.

Regards
Kiran

Nov 16 '05 #2
Hi Trillium,

Thanks for the reply, and NO I am still looking for a way to achieve this.

I had the impression that SchemaGen = true will drop & recreate the table.
but I don't mind if its set to false as well, all I am looking for is to be
able to load the data from XML file in to SQL tables without having to
create any files thing manually.

Regards
Kiran

"Trillium" <Tr******@discu ssions.microsof t.com> wrote in message
news:DD******** *************** ***********@mic rosoft.com...
This post was almost 2 weeks ago now, so I hope you got the answer by now. If not, here are my 2 bits.
As I understand it, SQLXMLBulkLoad. SchemaGen refers to creating the SQL tables into which the data will go in the BulkLoad, not to creating the
schema (xsd). It takes the place of the CREATE TABLE (...) SQL command. So
if true, the tables are created if they don't already exist (if they do, the
data goes into the existing tables).
"Kiran" wrote:
Hi,

I want to back up my data in some table in SQL server and import it back
using Bulk Load of SQL server 2K.

I can use the following code to backup the data in XML

dataset.WriteXm l(@"C:\Data.xml ");
dataset.WriteXm lSchema(@"C:\Sc hema1.xml");

and following code to bulk import the same data

SQLXMLBULKLOADL ib.SQLXMLBulkLo ad3 x = new
SQLXMLBULKLOADL ib.SQLXMLBulkLo ad3Class();
x.ConnectionStr ing
="PROVIDER=SQLO LEDB.1;SERVER=l ocalhost;UID=sa ;PWD=;DATABASE= demo01";
x.XMLFragment = true;
x.ErrorLogFile = @"c:\error.txt" ;
x.SchemaGen = true;
x.SGDropTables = true;
x.Execute(@"C:\ Schema.xml",@"C :\data.xml");

this do not work, but do not thoow any error either, when I looked
closely... the format of the schema file is incorrect, if I create a correct formate maually it works.

Does some one know how to generate schema file in correct format? using
..Net.

Regards
Kiran

Nov 16 '05 #3
From what I understand of SQLXMLBULKLOAD, it is only for importing data. I don't think it has any ability to query the db table structure besides reporting (or not!) that an insert failed because of unmatched datatype. But for sure it has to have an existing schema as the first parameter for execute (which I THINK can be a also be stream), before it can do anything.

It seems to me that you'd have to query the database structure and create the schemas and save them somehow before doing the backup. Then use the schemas created in that process with bulkload. I have not done anything like this and have done very little with .NET yet, but it seems to me there would be something that might do the db structure/create schema in the SqlXml, SqlXmlAdapter and/or SqlXmlCommand classes. Or one of the oledb or sql client data retrieval classes.

I hope you are successful soon.

"Kiran" wrote:
Hi Trillium,

Thanks for the reply, and NO I am still looking for a way to achieve this.

I had the impression that SchemaGen = true will drop & recreate the table.
but I don't mind if its set to false as well, all I am looking for is to be
able to load the data from XML file in to SQL tables without having to
create any files thing manually.

Regards
Kiran

"Trillium" <Tr******@discu ssions.microsof t.com> wrote in message
news:DD******** *************** ***********@mic rosoft.com...
This post was almost 2 weeks ago now, so I hope you got the answer by now.

If not, here are my 2 bits.

As I understand it, SQLXMLBulkLoad. SchemaGen refers to creating the SQL

tables into which the data will go in the BulkLoad, not to creating the
schema (xsd). It takes the place of the CREATE TABLE (...) SQL command. So
if true, the tables are created if they don't already exist (if they do, the
data goes into the existing tables).

"Kiran" wrote:
Hi,

I want to back up my data in some table in SQL server and import it back
using Bulk Load of SQL server 2K.

I can use the following code to backup the data in XML

dataset.WriteXm l(@"C:\Data.xml ");
dataset.WriteXm lSchema(@"C:\Sc hema1.xml");

and following code to bulk import the same data

SQLXMLBULKLOADL ib.SQLXMLBulkLo ad3 x = new
SQLXMLBULKLOADL ib.SQLXMLBulkLo ad3Class();
x.ConnectionStr ing
="PROVIDER=SQLO LEDB.1;SERVER=l ocalhost;UID=sa ;PWD=;DATABASE= demo01";
x.XMLFragment = true;
x.ErrorLogFile = @"c:\error.txt" ;
x.SchemaGen = true;
x.SGDropTables = true;
x.Execute(@"C:\ Schema.xml",@"C :\data.xml");

this do not work, but do not thoow any error either, when I looked
closely... the format of the schema file is incorrect, if I create a correct formate maually it works.

Does some one know how to generate schema file in correct format? using
..Net.

Regards
Kiran


Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4962
by: Chris | last post by:
Any help would be appreciated. I am running a script that does the following in succession. 1-Drop existing database and create new database 2-Defines tables, stored procedures and functions in the database 3-Imports data using bulk insert 4-Analyzes data using stored procedures I would like to improve the performance of the analysis in step 4 by
2
16500
by: php newbie | last post by:
Hello, I am trying to load a simple tab-delimited data file to SQL Server. I created a format file to go with it, since the data file differs from the destination table in number of columns. When I execute the query, I get an error saying that only sysadmin or bulkadmin roles are allowed to use the BULK INSERT statement. So, I proceeded with the Enterprise Manager to grant myself those roles. However, I could not find sysadmin or...
0
1839
by: gazmob | last post by:
Hi I am new to working with XML and am trying Bulk load data into MS SQL 2000 using VB.net on Visual Studio 2003. I add a ref to XBLKld4.ll The example code seems to be fairly easy to follow.
0
1495
by: Kiran | last post by:
Hi, Does some one here know how to trigger export(bulk/non bulk) and use bulk import without having to manually edit the Xsd file before import. BTW I am assuming that XML is the correct choice as I want to save these data in my VSS for future after export. ====================================== My prev Post:
11
28330
by: Ted | last post by:
OK, I tried this: USE Alert_db; BULK INSERT funds FROM 'C:\\data\\myData.dat' WITH (FIELDTERMINATOR='\t', KEEPNULLS, ROWTERMINATOR='\r\n');
4
10542
by: amjad | last post by:
Hi i have dataset which i write as xml file like ds.WriteXmlSchema(XSDFilename); ds.WriteXml(XMLFilename,XmlWriteMode.IgnoreSchema); then i try to load that file into sql using below code SQLXMLBULKLOADLib.SQLXMLBulkLoad4Class objBL = new SQLXMLBULKLOADLib.SQLXMLBulkLoad4Class(); objBL.ConnectionString = "Provider=SQLOLEDB;server=cwp01004s;database=TestBulkLoad;uid=amjad;pwd=mirror;Trust_Connection=True";
0
3007
by: ozkhillscovington | last post by:
We have sp's in place that do BULK INSERTS from txt files into the tables. This works fine, however they have asked us to add a field that identifies accounting ctr. The only thing that identifies accounting ctr is the last three letters of the text file being used for the BULK INSERT. How would you suggest that I do this? Is there a way to add a default value to the .fmt or schema files for the text fields, or in the BULK INSERT...
1
1721
by: mharrison | last post by:
Hi All, I'm using SQL 2000 and in a DTS I want to load in an error XML file to a SQL table. I am using the SQLXMLBulkLoad component in an Active X script. I have an XML file. see below, and also an XSD schema file. Could someone take a look and see where I am going wrong??! I get an error from SQL stating "Relationship expected on errors"
1
3014
by: Ted | last post by:
I found this quite interesting. However, it seems to assume I have a schema defined in an xsd or xdr file. I get a data feed that appears to be well formed XML, but there is no schema. Is it possible to bulk load XML data without a schema file being available? If not, is there a tool that will create a schema from a sample XML file?
0
8395
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8310
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8826
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7330
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6166
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4155
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4306
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.