显示标签为“application”的博文。显示所有博文
显示标签为“application”的博文。显示所有博文

2012年3月29日星期四

bcp_bind and SQL DATETIME type

Hi all,
I'm working on a simple ODBC API bulk load application and I've run
into a problem. I am binding variables in memory and sending the rows
as prescribed in the ODBC 3.0 API Reference and on MSDN. Everything
works fine for SQL VARCHAR and SQL INTEGER data types; however, I run
into issues when I try to bind SQL DATETIME data types. I can't seem
to find examples of how this should be done anywhere... Should my
variable that I'm binding to be a C-Style string or a
SQL_TIMESTAMP_STRUCT or a time_t structure? It's all a blur...
Anyone know where I can find a sample that bcp_binds to a DATETIME
column in a table?
TIANever mind, issue resolved.
"Michael C#" wrote:

> Hi all,
> I'm working on a simple ODBC API bulk load application and I've run
> into a problem. I am binding variables in memory and sending the rows
> as prescribed in the ODBC 3.0 API Reference and on MSDN. Everything
> works fine for SQL VARCHAR and SQL INTEGER data types; however, I run
> into issues when I try to bind SQL DATETIME data types. I can't seem
> to find examples of how this should be done anywhere... Should my
> variable that I'm binding to be a C-Style string or a
> SQL_TIMESTAMP_STRUCT or a time_t structure? It's all a blur...
> Anyone know where I can find a sample that bcp_binds to a DATETIME
> column in a table?
> TIA
>|||Hello Michael,
Can you please show me an example that "works fine for SQL VARCHAR"? I just
can't send text using the bcp...
TIA
quote:
Originally posted by Michael C
Never mind, issue resolved.
"Michael C#" wrote:

> Hi all,
> I'm working on a simple ODBC API bulk load application and I've run
> into a problem. I am binding variables in memory and sending the rows
> as prescribed in the ODBC 3.0 API Reference and on MSDN. Everything
> works fine for SQL VARCHAR and SQL INTEGER data types; however, I run
> into issues when I try to bind SQL DATETIME data types. I can't seem
> to find examples of how this should be done anywhere... Should my
> variable that I'm binding to be a C-Style string or a
> SQL_TIMESTAMP_STRUCT or a time_t structure? It's all a blur...
> Anyone know where I can find a sample that bcp_binds to a DATETIME
> column in a table?
> TIA
>

|||Hi Michael, i am facing similar issue i.e. failing of bcp_binf for datetime
datatpye. Can You please share the solution that you have for this issue?
Thanks in advance.
From http://developmentnow.com/g/111_200...
ype.htm
Posted via DevelopmentNow.com Groups
http://www.developmentnow.com

2012年3月27日星期二

BCP with ODBC Native driver

We are using Visual Studio 2003 to develop a VC++ application to support SQL Server 2000 and 2005 through ODBC driver. I was able to successfully test the application with ODBC driver for 2000. But when it comes to the SQL Server 2005 using native ODBC driver it fails with "ODBCBCP.dll is not compatible with 'SQL Native Client' driver. Please configure 'SQL Server' driver for the DSN or connection string.

Then I tried to use the sqlncli.h inplace of odbcss.h and replaced the odbcbcp.lib with sqlncli.lib pointing to the C:\Program Files\Microsoft SQL Server\90\SDK\Lib\x86 folder.

Code Snippet

#include <sql.h>

#include <sqlext.h>

#include <sqltypes.h>

#define _SQLNCLI_ODBC_

#include <sqlncli.h>

Now I can not compile the program. The errors I am getting are as follows:

c:\Program Files\Microsoft SQL Server\90\SDK\Include\sqlncli.h(2894): error C2061: syntax error : identifier 'DB_UPARAMS'

c:\Program Files\Microsoft SQL Server\90\SDK\Include\sqlncli.h(2901): error C2061: syntax error : identifier 'DB_UPARAMS'
etc

c:\Program Files\Microsoft SQL Server\90\SDK\Include\sqlncli.h(2938): error C2061: syntax error : identifier 'HCHAPTER'
c:\Program Files\Microsoft SQL Server\90\SDK\Include\sqlncli.h(2944): error C2061: syntax error : identifier 'HCHAPTER'
etc

The same code just works fine in the Visual Studio 2005, but we need the dll in Visual studio 2003.

I think I am missing pretty obvious. Your help is appreciated.

Can you try not defining _SQLNCLI_ODBC_, I believe that would work.

Thanks

Waseem

sql

BCP vs SSIS

I have an application running on Unix that stores the information on
flat files. I want to be able to import all the data from some of those
files to SQL Server 2005 in order to create reports using reporting
services. After the initial import I want to be able to update (daily)
the tables on SQL Server with the changes to the flat files. What is
the more appropriate/easy tool for this scenario BCP or SSIS? Where I
can find information about how to create the "differential" import?
I recommand to create a package and load the flatfile and use a conditionnal
split to filter this flow for a particular date (or another information like
a sequential ID stored in the flat file)
(but this required that you must read the entire source flat file)
or, maybe, you can start reading at a particular row the flatfile.
in the 2 cases you have to store anywhere the last reading position.
I don't know if you can, but another option is to truncate this flat file
after processing.
in this case every day the file will contain only new rows.
or if you can create 1 file by day you'll have the better way to load the
data in your hand!!!
"Artificer" <eliezerfigueroa@.gmail.com> wrote in message
news:1159322299.987054.294170@.i42g2000cwa.googlegr oups.com...
>I have an application running on Unix that stores the information on
> flat files. I want to be able to import all the data from some of those
> files to SQL Server 2005 in order to create reports using reporting
> services. After the initial import I want to be able to update (daily)
> the tables on SQL Server with the changes to the flat files. What is
> the more appropriate/easy tool for this scenario BCP or SSIS? Where I
> can find information about how to create the "differential" import?
>
|||"Artificer" <eliezerfigueroa@.gmail.com> wrote in message
news:1159322299.987054.294170@.i42g2000cwa.googlegr oups.com...
>I have an application running on Unix that stores the information on
> flat files. I want to be able to import all the data from some of those
> files to SQL Server 2005 in order to create reports using reporting
> services. After the initial import I want to be able to update (daily)
> the tables on SQL Server with the changes to the flat files. What is
> the more appropriate/easy tool for this scenario BCP or SSIS? Where I
> can find information about how to create the "differential" import?
>
BCP can only do the load part. SSIS can do the end-to-end process. SSIS can
FTP the files down from your Unix box, Load them into staging tables, and
run SQL to merge them into your production tables.
SSIS can also do more complicated data flows if you want to do perform the
merge and any data cleansing logic using an SSIS Data Flow task instead of
SQL Queries.
David
|||Any recomended reading?
|||?
|||"Artificer" <eliezerfigueroa@.gmail.com> wrote in message
news:1159416107.959931.263660@.m73g2000cwd.googlegr oups.com...
> ?
>
Integration Services on MSDN
http://msdn2.microsoft.com/en-us/sql/aa336312.aspx
Microsoft SQL Server 2005 Integration Services
http://www.amazon.com/Microsoft-Serv.../dp/0672327813
Professional SQL Server 2005 Integration Services
http://www.amazon.com/Professional-S...dp/0764584359/
David

BCP vs SSIS

I have an application running on Unix that stores the information on
flat files. I want to be able to import all the data from some of those
files to SQL Server 2005 in order to create reports using reporting
services. After the initial import I want to be able to update (daily)
the tables on SQL Server with the changes to the flat files. What is
the more appropriate/easy tool for this scenario BCP or SSIS? Where I
can find information about how to create the "differential" import?I recommand to create a package and load the flatfile and use a conditionnal
split to filter this flow for a particular date (or another information like
a sequential ID stored in the flat file)
(but this required that you must read the entire source flat file)
or, maybe, you can start reading at a particular row the flatfile.
in the 2 cases you have to store anywhere the last reading position.
I don't know if you can, but another option is to truncate this flat file
after processing.
in this case every day the file will contain only new rows.
or if you can create 1 file by day you'll have the better way to load the
data in your hand!!!
"Artificer" <eliezerfigueroa@.gmail.com> wrote in message
news:1159322299.987054.294170@.i42g2000cwa.googlegroups.com...
>I have an application running on Unix that stores the information on
> flat files. I want to be able to import all the data from some of those
> files to SQL Server 2005 in order to create reports using reporting
> services. After the initial import I want to be able to update (daily)
> the tables on SQL Server with the changes to the flat files. What is
> the more appropriate/easy tool for this scenario BCP or SSIS? Where I
> can find information about how to create the "differential" import?
>|||"Artificer" <eliezerfigueroa@.gmail.com> wrote in message
news:1159322299.987054.294170@.i42g2000cwa.googlegroups.com...
>I have an application running on Unix that stores the information on
> flat files. I want to be able to import all the data from some of those
> files to SQL Server 2005 in order to create reports using reporting
> services. After the initial import I want to be able to update (daily)
> the tables on SQL Server with the changes to the flat files. What is
> the more appropriate/easy tool for this scenario BCP or SSIS? Where I
> can find information about how to create the "differential" import?
>
BCP can only do the load part. SSIS can do the end-to-end process. SSIS can
FTP the files down from your Unix box, Load them into staging tables, and
run SQL to merge them into your production tables.
SSIS can also do more complicated data flows if you want to do perform the
merge and any data cleansing logic using an SSIS Data Flow task instead of
SQL Queries.
David|||Any recomended reading?|||"Artificer" <eliezerfigueroa@.gmail.com> wrote in message
news:1159416107.959931.263660@.m73g2000cwd.googlegroups.com...
> ?
>
Integration Services on MSDN
http://msdn2.microsoft.com/en-us/sql/aa336312.aspx
Microsoft SQL Server 2005 Integration Services
http://www.amazon.com/Microsoft-Server-2005-Integration-Services/dp/0672327813
Professional SQL Server 2005 Integration Services
http://www.amazon.com/Professional-Server-Integration-Services-Programmer/dp/0764584359/
David

BCP vs SSIS

I have an application running on Unix that stores the information on
flat files. I want to be able to import all the data from some of those
files to SQL Server 2005 in order to create reports using reporting
services. After the initial import I want to be able to update (daily)
the tables on SQL Server with the changes to the flat files. What is
the more appropriate/easy tool for this scenario BCP or SSIS? Where I
can find information about how to create the "differential" import?I recommand to create a package and load the flatfile and use a conditionnal
split to filter this flow for a particular date (or another information like
a sequential ID stored in the flat file)
(but this required that you must read the entire source flat file)
or, maybe, you can start reading at a particular row the flatfile.
in the 2 cases you have to store anywhere the last reading position.
I don't know if you can, but another option is to truncate this flat file
after processing.
in this case every day the file will contain only new rows.
or if you can create 1 file by day you'll have the better way to load the
data in your hand!!!
"Artificer" <eliezerfigueroa@.gmail.com> wrote in message
news:1159322299.987054.294170@.i42g2000cwa.googlegroups.com...
>I have an application running on Unix that stores the information on
> flat files. I want to be able to import all the data from some of those
> files to SQL Server 2005 in order to create reports using reporting
> services. After the initial import I want to be able to update (daily)
> the tables on SQL Server with the changes to the flat files. What is
> the more appropriate/easy tool for this scenario BCP or SSIS? Where I
> can find information about how to create the "differential" import?
>|||"Artificer" <eliezerfigueroa@.gmail.com> wrote in message
news:1159322299.987054.294170@.i42g2000cwa.googlegroups.com...
>I have an application running on Unix that stores the information on
> flat files. I want to be able to import all the data from some of those
> files to SQL Server 2005 in order to create reports using reporting
> services. After the initial import I want to be able to update (daily)
> the tables on SQL Server with the changes to the flat files. What is
> the more appropriate/easy tool for this scenario BCP or SSIS? Where I
> can find information about how to create the "differential" import?
>
BCP can only do the load part. SSIS can do the end-to-end process. SSIS can
FTP the files down from your Unix box, Load them into staging tables, and
run SQL to merge them into your production tables.
SSIS can also do more complicated data flows if you want to do perform the
merge and any data cleansing logic using an SSIS Data Flow task instead of
SQL Queries.
David|||Any recomended reading?|||"Artificer" <eliezerfigueroa@.gmail.com> wrote in message
news:1159416107.959931.263660@.m73g2000cwd.googlegroups.com...
> ?
>
Integration Services on MSDN
http://msdn2.microsoft.com/en-us/sql/aa336312.aspx
Microsoft SQL Server 2005 Integration Services
http://www.amazon.com/Microsoft-Ser...5
84359/
David

2012年3月11日星期日

BCP import with Blank lines in text file

I am trying to bcp import a text file into a SQL Server 2000 database.
The text file is coming out of a java application where order
information is written to the text file. Each record is on it's own
row, so the last item in each record has a new line character at the
end of it to create the next row. This works well in creating the file
however bcp does not like to import this text file with the extra blank
line at the end. If I change the new line character to the beginning of
the records then there is a blank line at the top of the text file,
which bcp also does not like. Does anyone have any suggestions for me
to get around this issue?

Thanks,EricR (erucevice@.gmail.com) writes:

Quote:

Originally Posted by

I am trying to bcp import a text file into a SQL Server 2000 database.
The text file is coming out of a java application where order
information is written to the text file. Each record is on it's own
row, so the last item in each record has a new line character at the
end of it to create the next row. This works well in creating the file
however bcp does not like to import this text file with the extra blank
line at the end. If I change the new line character to the beginning of
the records then there is a blank line at the top of the text file,
which bcp also does not like. Does anyone have any suggestions for me
to get around this issue?


For BCP questions it helps if you post the table definition, any format
file you use and a sample of the data file (if possible as an attachment).

If I understand this correctly, your file has a blank line beetween
every line with tect on:

231;yadayada;some more yadayada

2345;tuttelitugrd;straight on!

Specifying the row terminator as \r\n\r\n or \n\n if the file has
Unix format.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||Sorry for not including an example. My text file looks like this.
Order Number~Company Name~Product~Quantity~ID~User~Date~Site
Order Number~Company Name~Product~Quantity~ID~User~Date~Site
Order Number~Company Name~Product~Quantity~ID~User~Date~Site
Order Number~Company Name~Product~Quantity~ID~User~Date~Site

My format file is this.

8.0
8
1 SQLCHAR 0 50 "~" 1
OrderNum_
SQL_Latin1_General_CP1_CI_AS
2 SQLCHAR 0 50 "~" 2
SoldTo SQL_Latin1_General_CP1_CI_AS
3 SQLCHAR 0 50 "~" 3
Product SQL_Latin1_General_CP1_CI_AS
4 SQLCHAR 0 12 "~" 4
FulfillCount ""
5 SQLCHAR 0 50 "~" 5
HostID SQL_Latin1_General_CP1_CI_AS
6 SQLCHAR 0 10 "~" 6
User SQL_Latin1_General_CP1_CI_AS
7 SQLCHAR 0 12 "~" 7
Date SQL_Latin1_General_CP1_CI_AS
8 SQLCHAR 0 10 "\r\n" 8
Site SQL_Latin1_General_CP1_CI_AS

When the text file comes out of my Java application the last line
record has a carriage return which creates the blank line at the end of
the file. There are no blank lines between records. Thanks|||EricR (erucevice@.gmail.com) writes:

Quote:

Originally Posted by

When the text file comes out of my Java application the last line
record has a carriage return which creates the blank line at the end of
the file. There are no blank lines between records. Thanks


Ah, I think misunderstood you. So you file looks like this:

Order Number~Company Name~Product~Quantity~ID~User~Date~Site\r\n
Order Number~Company Name~Product~Quantity~ID~User~Date~Site\r\n
Order Number~Company Name~Product~Quantity~ID~User~Date~Site\r\n
Order Number~Company Name~Product~Quantity~ID~User~Date~Site\r\n
\r\n

Since I don't know Java, I need to ask a really stupid question: do
you really need that extra \r\n at the end? Can't you prevent Java
from adding it? Because, it can be quite difficult to get BCP to handle
that file. BCP believes in complete records so to speak.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||

Quote:

Originally Posted by

Since I don't know Java, I need to ask a really stupid question: do
you really need that extra \r\n at the end? Can't you prevent Java
from adding it? Because, it can be quite difficult to get BCP to handle
that file. BCP believes in complete records so to speak.


I can stop it from adding the new line character in Java but that is
easier said than done considering how my code is written. i have no way
of knowing how many records are going to be written to the text file
before the file is written. That is why I was hoping that there may be
some way within bcp to get it to ignore the last line, but the more I
play around with it the more I see that this is probably not possible.
Thanks for your suggestions.|||EricR (erucevice@.gmail.com) writes:

Quote:

Originally Posted by

I can stop it from adding the new line character in Java but that is
easier said than done considering how my code is written. i have no way
of knowing how many records are going to be written to the text file
before the file is written.


Not that I know how your code is written, but it does sound strange to
me, because as I understand it, you have two line feeds at the end.

Quote:

Originally Posted by

That is why I was hoping that there may be some way within bcp to get it
to ignore the last line, but the more I play around with it the more I
see that this is probably not possible.


There is an option -L to specify the last record to bulk-copy, but I would
not expect this to prevent any error since that last record is incomplete.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||On 8 Jan 2007 06:45:53 -0800, "EricR" <erucevice@.gmail.comwrote:

Quote:

Originally Posted by

>I can stop it from adding the new line character in Java but that is
>easier said than done considering how my code is written. i have no way
>of knowing how many records are going to be written to the text file
>before the file is written. That is why I was hoping that there may be
>some way within bcp to get it to ignore the last line, but the more I
>play around with it the more I see that this is probably not possible.
>Thanks for your suggestions.


Perhaps you can simply write a simple utility program that removes the
problematic line, and run the file through that before BCP. That is
the approach I have used for such problems in the past.

Roy Harvey
Beacon Falls, CT

2012年2月25日星期六

BCP call to import data from computer other than server is this possible?

Hi,

I have written an application which is being used by only 4 people on different computers. The one with SQL Server installed is comp0, then comp1, .... comp4.

Everything was working fine until today when the only user who is authorised (by my application) to perform the data import of BCP files, tried to import the latest BCP files. I am making my bcp command line string and then calling it using the VB Shell call.

If I run the import option from my app on the server it works fine. So at first I thought, ah, the BCP files won't be in the other computers path. I've copied BCP.EXE and BCP.rll but it still doesn't work.

Is it even possible to run BCP from a computer other than the one with SQL Server installed? I really need the import to work on a computer other than the server.

Thanks in advance,

Paul

Hi Paul,

What is the bcp command you are tyring to call exactly?

Thanks

Cris

|||

Hi Cris,

The calls is as follows:

strBCPCommand = "bcp database_name.schema." & _

table_name & _

" in " & _

full_path_of_bcp file & _

" -n -T -Sserver_name\sql -V65"

It all works fine when called from the application or command line on the server.

Thanks,

Paul

2012年2月23日星期四

bcp api and error handling

I have implemented a VB.NET application which uses the ODBC BCP api to bulk
insert data into a Microsoft SQL 2000 database. I have included error
handling as it is important to trap and log any errors when they occur. The
import works fine, and the error handling works fine for any ODBC errors
(server not found, login problems etc are all logged properly).
The problem is that ANY bcp error results in SQLGetDiagRec returning
SQL_NO_DATA. The same code works for the ODBC errors from the SQL* functions
,
but if any bcp_* function fails I always get SQL_NO_DATA. I am passing in th
e
connection handle with SQL_HANDLE_DBC as the handle type like the docs say,
but I have never managed to get a BCP error from this function.
Sometimes I can run the input files (I am using data and format files for
simplicity) with the command line bcp utility, and then I will see error
messages I can use. Sometimes the bcp utility works however, so I need the
error handling to find out what is going wrong. (The application is running
under COM+ as a special domain user for security reasons).
How should I use VB.NET to get the error messages when the ODBC BCP
functions fail? Why would my error handling code work for some errors but
return SQL_NO_DATA for others?Hi
I have never used this but, from your description it is hard to tell what is
failing, or even if you are using the correct error handling mechanism.
Posting sample code that can re-create your problem will help.
You may want to look at the example
http://msdn.microsoft.com/library/d...>
mp_4pm8.asp, although this is in C++.
John
"Stephen Davies" wrote:

> I have implemented a VB.NET application which uses the ODBC BCP api to bul
k
> insert data into a Microsoft SQL 2000 database. I have included error
> handling as it is important to trap and log any errors when they occur. Th
e
> import works fine, and the error handling works fine for any ODBC errors
> (server not found, login problems etc are all logged properly).
> The problem is that ANY bcp error results in SQLGetDiagRec returning
> SQL_NO_DATA. The same code works for the ODBC errors from the SQL* functio
ns,
> but if any bcp_* function fails I always get SQL_NO_DATA. I am passing in
the
> connection handle with SQL_HANDLE_DBC as the handle type like the docs say
,
> but I have never managed to get a BCP error from this function.
> Sometimes I can run the input files (I am using data and format files for
> simplicity) with the command line bcp utility, and then I will see error
> messages I can use. Sometimes the bcp utility works however, so I need the
> error handling to find out what is going wrong. (The application is runnin
g
> under COM+ as a special domain user for security reasons).
> How should I use VB.NET to get the error messages when the ODBC BCP
> functions fail? Why would my error handling code work for some errors but
> return SQL_NO_DATA for others?|||Hi,
Did you try the sample code included in SQL server setup CD? Please refer
to odbcerr.cpp for details.
http://msdn.microsoft.com/library/d...-us/odbcsql/od_
odbcsamp_4pm8.asp
Thanks & Regards,
Peter Yang
MCSE2000/2003, MCSA, MCDBA
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
========================================
=============
This posting is provided "AS IS" with no warranties, and confers no rights.
| Thread-Topic: bcp api and error handling
| thread-index: AcVAmXFPVsZNNvWPT5azzwfawDXxLg==
| X-WBNR-Posting-Host: 203.57.240.95
| From: "examnotes" <chalky@.newsgroup.nospam>
| Subject: bcp api and error handling
| Date: Wed, 13 Apr 2005 19:27:02 -0700
| Lines: 21
| Message-ID: <B608ADB0-3DFC-438D-89A4-45D4582D87C1@.microsoft.com>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.sqlserver.programming
| Path: TK2MSFTNGXA01.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.sqlserver.programming:85683
| NNTP-Posting-Host: tk2msftngxa03.phx.gbl 10.40.2.157
| X-Tomcat-NG: microsoft.public.sqlserver.programming
|
| I have implemented a VB.NET application which uses the ODBC BCP api to
bulk
| insert data into a Microsoft SQL 2000 database. I have included error
| handling as it is important to trap and log any errors when they occur.
The
| import works fine, and the error handling works fine for any ODBC errors
| (server not found, login problems etc are all logged properly).
|
| The problem is that ANY bcp error results in SQLGetDiagRec returning
| SQL_NO_DATA. The same code works for the ODBC errors from the SQL*
functions,
| but if any bcp_* function fails I always get SQL_NO_DATA. I am passing in
the
| connection handle with SQL_HANDLE_DBC as the handle type like the docs
say,
| but I have never managed to get a BCP error from this function.
|
| Sometimes I can run the input files (I am using data and format files for
| simplicity) with the command line bcp utility, and then I will see error
| messages I can use. Sometimes the bcp utility works however, so I need
the
| error handling to find out what is going wrong. (The application is
running
| under COM+ as a special domain user for security reasons).
|
| How should I use VB.NET to get the error messages when the ODBC BCP
| functions fail? Why would my error handling code work for some errors but
| return SQL_NO_DATA for others?
||||Thanks John and Peter for your responses.
I have created a sample and in doing so found an interesting phenomenon:
The code works in a "normal" app, but when run as a COM+ component it fails
to return BCP error messages. Commenting out the "Inherits ServicedComponent
"
line causes the error messages to work. Leave it in and I get SQL_NO_DATA.
I can't see how to add attachments with Microsoft's web based newsgroup
reader, so I signed up to geocities:
http://www.geocities.com/stephenchalkydavies/VbBcp.zip
How can I get BCP error messages when running in a COM+ application?
Thanks again,
Stephen|||Hi
This may be interesting
http://support.microsoft.com/defaul...kb;en-us;319243 but
nothing to do with COM+
John|||It doesn't mention COM+, and is talking about other methods (SQLGetData)
returning SQL_NO_DATA. I am getting bcp failures and the SQLGetDiagRec call
returns SQL_NO_DATA - but only when running in COM+.
I tried installing the MDAC patch anyway just in case - but it wouldn't
install, I think because I already upgraded to MDAC 2.8 and it is for 2.7.
Any more ideas? I really need to get the error handling working.
Thanks,
Stephen
"John Bell" wrote:

> Hi
> This may be interesting
> http://support.microsoft.com/defaul...kb;en-us;319243 but
> nothing to do with COM+
> John|||Hello Stephen,
Did you try SQLGetDiagRecW? The issue might be related to Unicode?
Also, you may want to contact our Develop Support Services by telephone so
that a dedicated Support Professional can assist you on this issue.To
obtain the phone numbers for specific technology request please take a look
at the web site listed below:
http://support.microsoft.com/defaul...S;PHONENUMBERS.
Best Regards,
Peter Yang
MCSE2000/2003, MCSA, MCDBA
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
========================================
=============
This posting is provided "AS IS" with no warranties, and confers no rights.
| Thread-Topic: bcp api and error handling
| thread-index: AcVDsxEOzHtU0b+iSc6szI5qAdg/Kw==
| X-WBNR-Posting-Host: 203.57.240.95
| From: "examnotes" <chalky@.newsgroup.nospam>
| References: <B608ADB0-3DFC-438D-89A4-45D4582D87C1@.microsoft.com>
<EA1606BF-08E9-45B2-A71A-ED1FCD739434@.microsoft.com>
<A3B4D1EE-DD56-4290-919C-0ED9ECE806F8@.microsoft.com>
<1113548068.421350.42470@.o13g2000cwo.googlegroups.com>
| Subject: Re: bcp api and error handling
| Date: Sun, 17 Apr 2005 18:08:01 -0700
| Lines: 21
| Message-ID: <98CECA7A-7E8A-43AD-9426-D2AA20A1821B@.microsoft.com>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.sqlserver.programming
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.sqlserver.programming:517122
| X-Tomcat-NG: microsoft.public.sqlserver.programming
|
| It doesn't mention COM+, and is talking about other methods (SQLGetData)
| returning SQL_NO_DATA. I am getting bcp failures and the SQLGetDiagRec
call
| returns SQL_NO_DATA - but only when running in COM+.
|
| I tried installing the MDAC patch anyway just in case - but it wouldn't
| install, I think because I already upgraded to MDAC 2.8 and it is for 2.7.
|
| Any more ideas? I really need to get the error handling working.
|
| Thanks,
| Stephen
|
| "John Bell" wrote:
|
| > Hi
| >
| > This may be interesting
| > http://support.microsoft.com/defaul...kb;en-us;319243 but
| > nothing to do with COM+
| >
| > John
||||Hi Peter,
I just tried SQLGetDiagRecW, but when I enabled COM+ (by un-commenting the
"Inherits ServicedComponent" line) I got the same SQL_NO_DATA return code
that I got with SQLGetDiagRec.
What could COM+ be doing that causes bcp to lose its errors?
Yesterday I tried running an ODBC trace. Outside of COM+, I see a [DIAG]
message in the trace followed by a successful call to SQLGetDiagRec. When ru
n
in COM+ the only difference is that the [DIAG] message is not in the trace
and hence the call to SQLGetDiagRec returns SQL_NO_DATA.
Is the error message getting stored somewhere else?
Thanks,
Stephen
"Peter Yang [MSFT]" wrote:

> Hello Stephen,
> Did you try SQLGetDiagRecW? The issue might be related to Unicode?|||Hello Stephen,
I haven't found a known issue on this behavior. Please contact our Develop
Support Services by telephone on debugging/dump analysis to further
troubleshoot this issue.
Regards,
Peter Yang
MCSE2000/2003, MCSA, MCDBA
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
========================================
=============
This posting is provided "AS IS" with no warranties, and confers no rights.
| Thread-Topic: bcp api and error handling
| thread-index: AcVEdfIhZtnSq5dWQby7kIwLKqtnvA==
| X-WBNR-Posting-Host: 203.57.240.95
| From: "examnotes" <chalky@.newsgroup.nospam>
| References: <B608ADB0-3DFC-438D-89A4-45D4582D87C1@.microsoft.com>
<EA1606BF-08E9-45B2-A71A-ED1FCD739434@.microsoft.com>
<A3B4D1EE-DD56-4290-919C-0ED9ECE806F8@.microsoft.com>
<1113548068.421350.42470@.o13g2000cwo.googlegroups.com>
<98CECA7A-7E8A-43AD-9426-D2AA20A1821B@.microsoft.com>
<VLbWZOARFHA.2316@.TK2MSFTNGXA02.phx.gbl>
| Subject: Re: bcp api and error handling
| Date: Mon, 18 Apr 2005 17:23:01 -0700
| Lines: 24
| Message-ID: <90CF8356-0BCF-4740-91A6-F29889FC0A24@.microsoft.com>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.sqlserver.programming
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.sqlserver.programming:517422
| X-Tomcat-NG: microsoft.public.sqlserver.programming
|
| Hi Peter,
|
| I just tried SQLGetDiagRecW, but when I enabled COM+ (by un-commenting
the
| "Inherits ServicedComponent" line) I got the same SQL_NO_DATA return code
| that I got with SQLGetDiagRec.
|
| What could COM+ be doing that causes bcp to lose its errors?
|
| Yesterday I tried running an ODBC trace. Outside of COM+, I see a [DIAG]
| message in the trace followed by a successful call to SQLGetDiagRec. When
run
| in COM+ the only difference is that the [DIAG] message is not in the
trace
| and hence the call to SQLGetDiagRec returns SQL_NO_DATA.
|
| Is the error message getting stored somewhere else?
|
| Thanks,
| Stephen
|
| "Peter Yang [MSFT]" wrote:
|
| > Hello Stephen,
| >
| > Did you try SQLGetDiagRecW? The issue might be related to Unicode?
|
|

2012年2月18日星期六

BCP - BULK INSERT - Memory mapped files

Hi,
I have an application server which receives several thousand events per
second. And it needs to store that data in an SQL server running on a
separate server connected thru network to the application server. I would
like to know the fastest and the efficient way to store the data in to SQL
server tables.
I looked in to BCP and BULK INSERT, but the question is how do I move the
data file(presumably created by the application server) to the SQL server to
use with BULK INSERT? I can probably create the file locally on the
application server, and use bcp_execute etc programatically, but is this the
best way? Since the data is already in the application memory, is it possible
make bcp_execute access the in-memory data, using memory-mapped file or some
such thing?
Thank you for your help, Srini
Check SqlBulkCopy class in msdn or .Net documentation.
You can feed it with any object (WriteToServer method) implementing
IDataReader
HTH
"Srini" <Srini@.discussions.microsoft.com> wrote in message
news:AB6E2972-4C04-47AE-BA3D-1BF7EEE827A5@.microsoft.com...
> Hi,
> I have an application server which receives several thousand events per
> second. And it needs to store that data in an SQL server running on a
> separate server connected thru network to the application server. I would
> like to know the fastest and the efficient way to store the data in to SQL
> server tables.
> I looked in to BCP and BULK INSERT, but the question is how do I move the
> data file(presumably created by the application server) to the SQL server
> to
> use with BULK INSERT? I can probably create the file locally on the
> application server, and use bcp_execute etc programatically, but is this
> the
> best way? Since the data is already in the application memory, is it
> possible
> make bcp_execute access the in-memory data, using memory-mapped file or
> some
> such thing?
> Thank you for your help, Srini
|||I am not using .Net Framework in my code. I need a solution using ODBC or BCP
API. etc.
Thanks for your help.
"AlexS" wrote:

> Check SqlBulkCopy class in msdn or .Net documentation.
> You can feed it with any object (WriteToServer method) implementing
> IDataReader
> HTH
> "Srini" <Srini@.discussions.microsoft.com> wrote in message
> news:AB6E2972-4C04-47AE-BA3D-1BF7EEE827A5@.microsoft.com...
>
>
|||Look up bcp_bind and bcp_sendrow in MSDN
"Srini" <Srini@.discussions.microsoft.com> wrote in message
news:62EB5419-1361-40BA-A66E-40EC2817A5BC@.microsoft.com...[vbcol=seagreen]
>I am not using .Net Framework in my code. I need a solution using ODBC or
>BCP
> API. etc.
> Thanks for your help.
> "AlexS" wrote:

BCP - BULK INSERT - Memory mapped files

Hi,
I have an application server which receives several thousand events per
second. And it needs to store that data in an SQL server running on a
separate server connected thru network to the application server. I would
like to know the fastest and the efficient way to store the data in to SQL
server tables.
I looked in to BCP and BULK INSERT, but the question is how do I move the
data file(presumably created by the application server) to the SQL server to
use with BULK INSERT? I can probably create the file locally on the
application server, and use bcp_execute etc programatically, but is this the
best way? Since the data is already in the application memory, is it possibl
e
make bcp_execute access the in-memory data, using memory-mapped file or some
such thing?
Thank you for your help, SriniCheck SqlBulkCopy class in msdn or .Net documentation.
You can feed it with any object (WriteToServer method) implementing
IDataReader
HTH
"Srini" <Srini@.discussions.microsoft.com> wrote in message
news:AB6E2972-4C04-47AE-BA3D-1BF7EEE827A5@.microsoft.com...
> Hi,
> I have an application server which receives several thousand events per
> second. And it needs to store that data in an SQL server running on a
> separate server connected thru network to the application server. I would
> like to know the fastest and the efficient way to store the data in to SQL
> server tables.
> I looked in to BCP and BULK INSERT, but the question is how do I move the
> data file(presumably created by the application server) to the SQL server
> to
> use with BULK INSERT? I can probably create the file locally on the
> application server, and use bcp_execute etc programatically, but is this
> the
> best way? Since the data is already in the application memory, is it
> possible
> make bcp_execute access the in-memory data, using memory-mapped file or
> some
> such thing?
> Thank you for your help, Srini|||I am not using .Net Framework in my code. I need a solution using ODBC or BC
P
API. etc.
Thanks for your help.
"AlexS" wrote:

> Check SqlBulkCopy class in msdn or .Net documentation.
> You can feed it with any object (WriteToServer method) implementing
> IDataReader
> HTH
> "Srini" <Srini@.discussions.microsoft.com> wrote in message
> news:AB6E2972-4C04-47AE-BA3D-1BF7EEE827A5@.microsoft.com...
>
>|||Look up bcp_bind and bcp_sendrow in MSDN
"Srini" <Srini@.discussions.microsoft.com> wrote in message
news:62EB5419-1361-40BA-A66E-40EC2817A5BC@.microsoft.com...[vbcol=seagreen]
>I am not using .Net Framework in my code. I need a solution using ODBC or
>BCP
> API. etc.
> Thanks for your help.
> "AlexS" wrote:
>

2012年2月13日星期一

Batch performance degradation - SQL Server 2000

I am running a VB.net console (batch) application that performs 50,000 sets
of reads, inserts, and updates to numerous SQL Server 2000 database tables.
Each individual set is mutually exclusive from the previous or subsequent
sets. I am monitoring the average processing time per set. When I start
the program, the average processing time is very small. However, the
average processing time slowly grows by about 67% by the end of the 50,000
sets. If I start another group of 50,000 right away, the processing time at
the beginning is again very fast. But, again, the performance degrades as
the program runs.
I've added more RAM to the server, increased the minimum buffer pool size,
and removed all of the constraints from the tables being inserted or
updated. None of these have eliminated nor reduced the degradation. I've
generated traces using Profiler, but have not been able to identify a stored
procedure that takes longer and longer to execute as the program progresses.
Can anyone suggest any other places to investigate?
Thanks,
Dan
Are you updating all 50K records as a single transaction? If so, you could be slowing down as the transaction log grows. Try breaking the updates into smaller logical batches (say 1000 inserts/updates at a time) and issue a commit. This may solve your
problem....
Brad Feaker
Database Administrator

Batch performance degradation - SQL Server 2000

I am running a VB.net console (batch) application that performs 50,000 sets
of reads, inserts, and updates to numerous SQL Server 2000 database tables.
Each individual set is mutually exclusive from the previous or subsequent
sets. I am monitoring the average processing time per set. When I start
the program, the average processing time is very small. However, the
average processing time slowly grows by about 67% by the end of the 50,000
sets. If I start another group of 50,000 right away, the processing time at
the beginning is again very fast. But, again, the performance degrades as
the program runs.
I've added more RAM to the server, increased the minimum buffer pool size,
and removed all of the constraints from the tables being inserted or
updated. None of these have eliminated nor reduced the degradation. I've
generated traces using Profiler, but have not been able to identify a stored
procedure that takes longer and longer to execute as the program progresses.
Can anyone suggest any other places to investigate?
Thanks,
DanAre you updating all 50K records as a single transaction? If so, you could
be slowing down as the transaction log grows. Try breaking the updates into
smaller logical batches (say 1000 inserts/updates at a time) and issue a co
mmit. This may solve your
problem....
Brad Feaker
Database Administrator

Batch performance degradation - SQL Server 2000

I am running a VB.net console (batch) application that performs 50,000 sets
of reads, inserts, and updates to numerous SQL Server 2000 database tables.
Each individual set is mutually exclusive from the previous or subsequent
sets. I am monitoring the average processing time per set. When I start
the program, the average processing time is very small. However, the
average processing time slowly grows by about 67% by the end of the 50,000
sets. If I start another group of 50,000 right away, the processing time at
the beginning is again very fast. But, again, the performance degrades as
the program runs.
I've added more RAM to the server, increased the minimum buffer pool size,
and removed all of the constraints from the tables being inserted or
updated. None of these have eliminated nor reduced the degradation. I've
generated traces using Profiler, but have not been able to identify a stored
procedure that takes longer and longer to execute as the program progresses.
Can anyone suggest any other places to investigate?
Thanks,
DanAre you updating all 50K records as a single transaction? If so, you could be slowing down as the transaction log grows. Try breaking the updates into smaller logical batches (say 1000 inserts/updates at a time) and issue a commit. This may solve your problem...
Brad Feake
Database Administrator

Batch file and use of isql command

Hi,
I'm trying to figure out how to be able to run a batch
file, go to the database, find the current application
version of our product and based on that result it
returns, run a specific script. We have a table that
holds all of the builds/releases of the application that
have been applied against the database. Based on the
information there (the max build/release number), I want
it to execute a specific SQL script that will upgrade them
to the next build/release.
For example, we have a table called DBVersion with one
column in it (AppsVersion). In this table, it has rows
that are as follows:
8.0.100.0
8.0.101.0
8.0.102.0
We have two upgrade paths that we will support. In the
example above, we can upgrade a customer who are in
8.0.100.0 or 8.0.102.0 to the new release number
8.0.103.0. We have two upgrade scripts...one that holds
all db changes from 8.0.100.0 to 8.0.103.0 and one that
holds all db changes from 8.0.102.0 to 8.0.103.0. I want
to create a batch file that finds the version they are on
and run a specific script to upgrade them to the new
release.
Thank you in advance,
DeeHi, this line of SQL maybe helps you
SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'),
SERVERPROPERTY ('edition')
greatings, Cesar
"Dee" wrote:
> Hi,
> I'm trying to figure out how to be able to run a batch
> file, go to the database, find the current application
> version of our product and based on that result it
> returns, run a specific script. We have a table that
> holds all of the builds/releases of the application that
> have been applied against the database. Based on the
> information there (the max build/release number), I want
> it to execute a specific SQL script that will upgrade them
> to the next build/release.
> For example, we have a table called DBVersion with one
> column in it (AppsVersion). In this table, it has rows
> that are as follows:
> 8.0.100.0
> 8.0.101.0
> 8.0.102.0
> We have two upgrade paths that we will support. In the
> example above, we can upgrade a customer who are in
> 8.0.100.0 or 8.0.102.0 to the new release number
> 8.0.103.0. We have two upgrade scripts...one that holds
> all db changes from 8.0.100.0 to 8.0.103.0 and one that
> holds all db changes from 8.0.102.0 to 8.0.103.0. I want
> to create a batch file that finds the version they are on
> and run a specific script to upgrade them to the new
> release.
> Thank you in advance,
> Dee
>|||Hi Cesar,
Thank you for your response. Actually, the version that I
was implying was our own product's application version and
not SQL Server's.
Thanks again,
Dee
>--Original Message--
>Hi, this line of SQL maybe helps you
>SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY
('productlevel'),
>SERVERPROPERTY ('edition')
>greatings, Cesar
>"Dee" wrote:
>> Hi,
>> I'm trying to figure out how to be able to run a batch
>> file, go to the database, find the current application
>> version of our product and based on that result it
>> returns, run a specific script. We have a table that
>> holds all of the builds/releases of the application
that
>> have been applied against the database. Based on the
>> information there (the max build/release number), I
want
>> it to execute a specific SQL script that will upgrade
them
>> to the next build/release.
>> For example, we have a table called DBVersion with one
>> column in it (AppsVersion). In this table, it has rows
>> that are as follows:
>> 8.0.100.0
>> 8.0.101.0
>> 8.0.102.0
>> We have two upgrade paths that we will support. In the
>> example above, we can upgrade a customer who are in
>> 8.0.100.0 or 8.0.102.0 to the new release number
>> 8.0.103.0. We have two upgrade scripts...one that
holds
>> all db changes from 8.0.100.0 to 8.0.103.0 and one that
>> holds all db changes from 8.0.102.0 to 8.0.103.0. I
want
>> to create a batch file that finds the version they are
on
>> and run a specific script to upgrade them to the new
>> release.
>> Thank you in advance,
>> Dee
>.
>

2012年2月12日星期日

Batch execute of SQL script from ADO.Net

I have a VB.Net application that needs to create about 5 stored
procedures and a couple of functions on SQL Server 2005 Express.
Currently I can execute all of them in one window of Sql Server
Management Studio, just separate each of them with a "GO" statement. Is
there a way I can accomplish this "one shot" approach via ADO.Net in my
application? If so, I can just put all my ddl SQL code in a text file
as an embedded resource, and then execute it in a couple of lines of
code. However, I suspect that I need to execute each ddl statement
separately and thus will need to parse the text file to break it up, or
break the sql code into multiple files, one for each stored proc.
Thanks for your thoughts,
Marcus[Reposted, as posts from outside msnews.microsoft.com does not seem to make
it in.]
Marcus (holysmokes99@.hotmail.com) writes:
> I have a VB.Net application that needs to create about 5 stored
> procedures and a couple of functions on SQL Server 2005 Express.
> Currently I can execute all of them in one window of Sql Server
> Management Studio, just separate each of them with a "GO" statement. Is
> there a way I can accomplish this "one shot" approach via ADO.Net in my
> application? If so, I can just put all my ddl SQL code in a text file
> as an embedded resource, and then execute it in a couple of lines of
> code. However, I suspect that I need to execute each ddl statement
> separately and thus will need to parse the text file to break it up, or
> break the sql code into multiple files, one for each stored proc.
Yes, if you read this file from your own application, you will need to
parse the file for "go" and send down batch by batch with ExcecuteNonQuery.
Parsing the file for "go" is a trivial matter.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.seBooks Online for SQL
Server 2005
athttp://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000
athttp://www.microsoft.com/sql/prodinfo/previousversions/books.mspx