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

2012年3月25日星期日

BCP Troubles

We are trying to move data from a product called TABLEBase that runs on
the mainframe and we are experiencing problems trying to BCP the data
into SQL Server. The SQL server we are tying to BCP into is SQL 2000.
We are using BCP from a command prompt.

Here is what happens.

the first time it doesn't load anything and we get no messages.The only
way I got it to work was to run BCP and have it create a ForMaT file.
I compared the ForMat file I created by hand,to the ForMat file I
created from BCP they are identical. (I used a product called beyond
compare to check it). After I created the ForMaT file and loaded the
data, I then deleted the data and ran it with the original ForMaT file
(no changes) and the data loaded fine this time.

Has anyone else run into this before? It is driving us nuts!dataguy (barry_noble@.progressive.com) writes:
> We are trying to move data from a product called TABLEBase that runs on
> the mainframe and we are experiencing problems trying to BCP the data
> into SQL Server. The SQL server we are tying to BCP into is SQL 2000.
> We are using BCP from a command prompt.
> Here is what happens.
> the first time it doesn't load anything and we get no messages.The only
> way I got it to work was to run BCP and have it create a ForMaT file.
> I compared the ForMat file I created by hand,to the ForMat file I
> created from BCP they are identical. (I used a product called beyond
> compare to check it). After I created the ForMaT file and loaded the
> data, I then deleted the data and ran it with the original ForMaT file
> (no changes) and the data loaded fine this time.
> Has anyone else run into this before? It is driving us nuts!

Is this repeatable? From your description, it sounds as it happened
once.

Or does the first attempt of every file fail silently? Do you really
have to use your own format file in between for the load to work?

Normally, I would ask for CREATE TABLE, format file and sample data file,
but I'm not sure that would be useful this time.

What I can say, that I cannot recall ever having run into that BCP
fails without message. As a matter of fact, BCP never completes
silently. So it sounds like the first time BCP is not executed at
all. Is it in a command file?

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Hi Erland,

Yes it is repeatable. It has happened more than once. The reason we
want to use our own Format file is that we are putting a process
together that will automate this. In other words if the table format
changes we want the format file to be automaticially updated.

This also is not a command file. That comes later once we get the
process refined. I am issuing the following command:

bcp d_CodeTableRepositorydb1.dbo.GBLECO in GBLECO.txt -fGBLECO.fmt
-SS65aa372 -T >>c:\output\GBLECO.OUT

At this time the format file and the input file are in the directory
where we are running the BCP command. We eventually will change this
to be fully qualified.|||dataguy (barry_noble@.progressive.com) writes:
> Yes it is repeatable. It has happened more than once.

OK, but does it happen every time, or is it intermittently?

> The reason we want to use our own Format file is that we are putting a
> process together that will automate this. In other words if the table
> format changes we want the format file to be automaticially updated.

Using your own format file is a very normal thing to do.

Since you compare the files in Beyond Compare, the only thing I can
think of is that your file has trailing spaces or different line
terminators. But in such case it should not work the second time
round - unless you save the line from some tool on the way.

> This also is not a command file. That comes later once we get the
> process refined. I am issuing the following command:
> bcp d_CodeTableRepositorydb1.dbo.GBLECO in GBLECO.txt -fGBLECO.fmt
> -SS65aa372 -T >>c:\output\GBLECO.OUT

Shouldn't you have a 2>&1 to also get errors into the output file?
You can also use -e to errors from the bulk-copying itself, but I don't
think this would matter here.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||It is happening everytime.

I got a brainstorm and figured I could run a BCP and create the format
file first prior to doing the BCP in.. When I tried running BCP with a
format as the output I keep getting the following error:

SQLState = S1090, NativeError = 0
Error = [Microsoft][ODBC SQL Server Driver]Invalid string or buffer
length

Any suggestions?

I checked MSDN and couldn't see anything regarding this error and DTS..|||dataguy (barry_noble@.progressive.com) writes:
> It is happening everytime.

That's a good thing. :-) I mean this makes it easier to repeat. Could
you post the CREATE TABLE statement for table, sample data and the
format file. But please put the sample data and format file in a zip
file to attach that.

> I got a brainstorm and figured I could run a BCP and create the format
> file first prior to doing the BCP in.. When I tried running BCP with a
> format as the output I keep getting the following error:
> SQLState = S1090, NativeError = 0
> Error = [Microsoft][ODBC SQL Server Driver]Invalid string or buffer
> length
> Any suggestions?

BCP's error messages are sometimes very obscure. What was the command
you used to achieve this?

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Couldn't it be a security issue?
In your command line I don't see any user parameters (account plus password)
that will be used by bcp. Is that correct and does the default user has
sufficient rights to import the data?

Maurits

"dataguy" <barry_noble@.progressive.com> schreef in bericht
news:1123617714.497837.183870@.g44g2000cwa.googlegr oups.com...
> We are trying to move data from a product called TABLEBase that runs on
> the mainframe and we are experiencing problems trying to BCP the data
> into SQL Server. The SQL server we are tying to BCP into is SQL 2000.
> We are using BCP from a command prompt.
> Here is what happens.
> the first time it doesn't load anything and we get no messages.The only
> way I got it to work was to run BCP and have it create a ForMaT file.
> I compared the ForMat file I created by hand,to the ForMat file I
> created from BCP they are identical. (I used a product called beyond
> compare to check it). After I created the ForMaT file and loaded the
> data, I then deleted the data and ran it with the original ForMaT file
> (no changes) and the data loaded fine this time.
> Has anyone else run into this before? It is driving us nuts!

2012年2月16日星期四

bckhist.cpp - Failed Assertion = 'm_markCVount < m_maxLogMarks'

The SQL Server (Product Version 8.00..., SQL Server 2000) writes the follow
ing errors:
- SQL Server Assertion: File: >bckhist.cpp>, line=1742, Failed Assertion = '
m_MarkCount < m_maxLogMarks'
- Error: 3624, Severity: 20, State:1
- Error: 3449, Severity: 21, State:1, An error has occured that reequires SQ
LServer to shutdown so that recovery can be performed on database ID...
After these errors -> the SQLServer shutdown...
Please Help, thanks!This maybe an issue with the use of begin transaction with Mark Argument
that updates a table with trigger with insert.
Remove the with Mark argument from the being transaction to avoid the
issue.
If you need further information, I would suggest you open a call with
Microsoft support that will be able to assist you further with this issue.
Regards
Agnes Panosian
SQL Server Support

2012年2月13日星期一

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,
Dee
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
>
|||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'),[vbcol=seagreen]
>SERVERPROPERTY ('edition')
>greatings, Cesar
>"Dee" wrote:
that[vbcol=seagreen]
want[vbcol=seagreen]
them[vbcol=seagreen]
holds[vbcol=seagreen]
want[vbcol=seagreen]
on
>.
>

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:
>
that[vbcol=seagreen]
want[vbcol=seagreen]
them[vbcol=seagreen]
holds[vbcol=seagreen]
want[vbcol=seagreen]
on[vbcol=seagreen]
>.
>

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月11日星期六

Basic SQL question...

Hello, folks.

I have the following query that I run that pulls up the count of the number of orders of a product.

SELECT Product, Count(Product) AS Total
FROM Orders_View
GROUP BY Product, Year([DateOpened]), Month([DateOpened])
HAVING (((Year([DateOpened]))=2004) AND ((Month([DateOpened]))=10))
ORDER BY Product;

This query is fine but the COUNT() function only coughs-up the non-zero results. How can I get this query to cough-up the zero counts as well for all products listed in the Product table?

TIA...Count(Product) will count non-null columns. To count null columns
either use ISNULL function or count(*).

SELECT Product, Count(isnull(Product,0)) AS Total
FROM Orders_View
GROUP BY Product, Year([DateOpened]), Month([DateOpened])
HAVING (((Year([DateOpened]))=2004) AND ((Month([DateOpened]))=10))
ORDER BY Product;

SELECT Product, Count(*) AS Total
FROM Orders_View
GROUP BY Product, Year([DateOpened]), Month([DateOpened])
HAVING (((Year([DateOpened]))=2004) AND ((Month([DateOpened]))=10))
ORDER BY Product;|||Blue Streak wrote:
> Hello, folks.
> I have the following query that I run that pulls up the count of the
number of orders of a product.
> SELECT Product, Count(Product) AS Total
> FROM Orders_View
> GROUP BY Product, Year([DateOpened]), Month([DateOpened])
> HAVING (((Year([DateOpened]))=2004) AND ((Month([DateOpened]))=10))
> ORDER BY Product;
> This query is fine but the COUNT() function only coughs-up the
non-zero results. How can I get this query to cough-up the zero counts
as well for all products listed in the Product table?
> TIA...

SELECT Product,
(SELECT COUNT(*)
FROM Orders_View
WHERE Orders_View.Product = Product.Product
AND Year([DateOpened])=2004
AND Month([DateOpened])=10) AS ProductSales
FROM Product

--
David Rowland
http://dbmonitor.tripod.com|||Blue Streak (anonymous@.msn.com) writes:
> I have the following query that I run that pulls up the count of the
> number of orders of a product.
> SELECT Product, Count(Product) AS Total
> FROM Orders_View
> GROUP BY Product, Year([DateOpened]), Month([DateOpened])
> HAVING (((Year([DateOpened]))=2004) AND ((Month([DateOpened]))=10))
> ORDER BY Product;
> This query is fine but the COUNT() function only coughs-up the non-zero
> results. How can I get this query to cough-up the zero counts as well
> for all products listed in the Product table?

It is always adviceable for this type of question to post:

1) CREATE TABLE statement for your tables (and in this case also the view)
2) INSERT statements with sample data.
3) The desired output given the sample data.

That permits anyone answering your question to easily cut and paste into
to Query Analyzer and develop a tested solution.

The solution suggested by David Rowland should give you the desired
result, but it may not be that performant.

An alternative is to explorr GROUP BY ALL, but with out the table and
view definitions, I can't test.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||You might want work on better names for data elements. A name should
tell us what the data element is, and not how it is stored (i.e. VIEW);
it ought to tell us the attribute involved (product what? Weight? Size?
Id?)

Since you did not bother with DDL, I am going to assume that there is
Products table somewhere and that this will work.

SELECT P.product_id, COUNT(O.product_id) AS total
FROM Products AS P
LEFT OUTER JOIN
Orders AS O
ON P.product_id = O.product_id
WHERE O.date_opened BETWEEN '2004-10-01 00:00:00.000'
AND '2004-10-31 23:59:59.99'
GROUP BY I.product_id;

Hint about temporal data: do not split it up into pieces to do numeric
or string operations on the conversions. Think of it as a data type in
its own right, with its own operators. This is not just a matter of the
extra overhead, but the way you approach a problem.|||10Q very much!

"louis" <louisducnguyen@.gmail.com> wrote in message
news:1108077906.182098.130540@.f14g2000cwb.googlegr oups.com...
> Count(Product) will count non-null columns. To count null columns
> either use ISNULL function or count(*).
> SELECT Product, Count(isnull(Product,0)) AS Total
> FROM Orders_View
> GROUP BY Product, Year([DateOpened]), Month([DateOpened])
> HAVING (((Year([DateOpened]))=2004) AND ((Month([DateOpened]))=10))
> ORDER BY Product;
> SELECT Product, Count(*) AS Total
> FROM Orders_View
> GROUP BY Product, Year([DateOpened]), Month([DateOpened])
> HAVING (((Year([DateOpened]))=2004) AND ((Month([DateOpened]))=10))
> ORDER BY Product;|||Mercy Buckets!!!!

This one worked!
"dbmonitor" <dbmonitor_support@.hotmail.com> wrote in message
news:1108087375.715820.99720@.g14g2000cwa.googlegro ups.com...
> Blue Streak wrote:
> > Hello, folks.
> > I have the following query that I run that pulls up the count of the
> number of orders of a product.
> > SELECT Product, Count(Product) AS Total
> > FROM Orders_View
> > GROUP BY Product, Year([DateOpened]), Month([DateOpened])
> > HAVING (((Year([DateOpened]))=2004) AND ((Month([DateOpened]))=10))
> > ORDER BY Product;
> > This query is fine but the COUNT() function only coughs-up the
> non-zero results. How can I get this query to cough-up the zero counts
> as well for all products listed in the Product table?
> > TIA...
> SELECT Product,
> (SELECT COUNT(*)
> FROM Orders_View
> WHERE Orders_View.Product = Product.Product
> AND Year([DateOpened])=2004
> AND Month([DateOpened])=10) AS ProductSales
> FROM Product
> --
> David Rowland
> http://dbmonitor.tripod.com