473,724 Members | 2,216 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 8089
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
4964
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
16506
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
1842
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
1502
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
28343
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
10545
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
3012
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
1724
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
3016
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
8868
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
9389
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...
0
9243
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9160
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
9090
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8063
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
6689
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...
1
3210
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2613
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.