2012年3月20日星期二
BCP OUT with Double Quote(") text qualifier?
It's easy to do in DTS by setting the connection properties of the Text File destination. The reason I can't use DTS is because my table has 329 fields and when I try to modify the destination properties of the transform task, Enterprise Manager bombs. I'd rather use BCP and a format file anyway.
Thanks,
Ray Metz
Everett, WAI just tried using a format file to define the field seperators as "," but BCP barfed. when I switched to ',' it worked. Maybe you could use this.|||Yeah, I had a similar idea to create a view with select '"' + field + '"' for each of the char columns. But since my export has over 300 columns and many of them char or varchar, I wanted an easier solution than going through each column.
Luckily, the Oracle DBA on the other end was ok with me not sending the quotes. The field seperator was a bar (|), and so far we haven't found any bars in the data so I think we're in good shape.
Thanks for your reply.
Ray
2012年2月16日星期四
BatchUpdateException
Hi,
Im having a problem with the SQL Server 2005 JDBC Driver v1.1, when it throws a BatchUpdateException it is not setting the vendor-specific error code! It is always returning zero for the error code. The exception is being thrown due to a Unique key contraint. It should be throwing the error codes ( 2627 or 2601 ) which were thrown by the SQl Server 2000 driver.
Can anyone explain?
Hi,
Let me research this and get back to you. It looks like it may be a bug in the 2005 driver. What driver version are you using (output from DatabaseMetaData.getDriverVersion())?
Thanks,
--David Olix (MSFT)
|||Hi David,
The driver version is 1.1.1501.101
Thanks again,
Cathal
|||
Ok, thanks. Two more questions for you then:
1. Does this behavior happen only when the key violation occurs on the first (or only) statement in the batch?
2. Are you seeing the behavior with Statement, but not PreparedStatement or CallableStatement?
If the answer is 'yes' to both of these then I believe it's a bug that we are currently targetting to fix in the next JDBC driver release around mid-year.
If that's not the problem, then you may may want to contact Microsoft Customer Support (support.microsoft.com) for further assistance.
Thanks again,
--David Olix (MSFT)
|||Hi David,
Thanks again for your reply. Our tests can confirm the behaviour you have outlined above. Could you give me some more detail about this bug, a tracking number etc? Just so we can keep track of it from our end.
Thanks,
Cathal
|||Hi David,
Thank you for your help with this issue. Would you be able to confirm my previous request for a bug tracking number for this issue. We are keeping track of it from our end and would like to close this issue as soon as possible.
Thanks again,
Cathal
|||Hi Cathal,
Sorry for not catching your previous post. I'm not quite sure what kind of tracking number you are requesting. We don't maintain a bug database for public reference. Would an internal bug tracking number help you any? Alternately, if you open a support case with Customer Support (support.microsoft.com), they will provide you with a case number that you can use for tracking. They may also be able to provide you with an unsupported interim build that contains the fix for development and testing purposes -- not for production. The fix will also be in the publicly available v1.2 CTP1, currently targeted for April.
Thanks again for your continued interest in this driver,
--David Olix [MSFT]
BatchUpdateException
Hi,
Im having a problem with the SQL Server 2005 JDBC Driver v1.1, when it throws a BatchUpdateException it is not setting the vendor-specific error code! It is always returning zero for the error code. The exception is being thrown due to a Unique key contraint. It should be throwing the error codes ( 2627 or 2601 ) which were thrown by the SQl Server 2000 driver.
Can anyone explain?
Hi,
Let me research this and get back to you. It looks like it may be a bug in the 2005 driver. What driver version are you using (output from DatabaseMetaData.getDriverVersion())?
Thanks,
--David Olix (MSFT)
|||Hi David,
The driver version is 1.1.1501.101
Thanks again,
Cathal
|||
Ok, thanks. Two more questions for you then:
1. Does this behavior happen only when the key violation occurs on the first (or only) statement in the batch?
2. Are you seeing the behavior with Statement, but not PreparedStatement or CallableStatement?
If the answer is 'yes' to both of these then I believe it's a bug that we are currently targetting to fix in the next JDBC driver release around mid-year.
If that's not the problem, then you may may want to contact Microsoft Customer Support (support.microsoft.com) for further assistance.
Thanks again,
--David Olix (MSFT)
|||Hi David,
Thanks again for your reply. Our tests can confirm the behaviour you have outlined above. Could you give me some more detail about this bug, a tracking number etc? Just so we can keep track of it from our end.
Thanks,
Cathal
|||Hi David,
Thank you for your help with this issue. Would you be able to confirm my previous request for a bug tracking number for this issue. We are keeping track of it from our end and would like to close this issue as soon as possible.
Thanks again,
Cathal
|||Hi Cathal,
Sorry for not catching your previous post. I'm not quite sure what kind of tracking number you are requesting. We don't maintain a bug database for public reference. Would an internal bug tracking number help you any? Alternately, if you open a support case with Customer Support (support.microsoft.com), they will provide you with a case number that you can use for tracking. They may also be able to provide you with an unsupported interim build that contains the fix for development and testing purposes -- not for production. The fix will also be in the publicly available v1.2 CTP1, currently targeted for April.
Thanks again for your continued interest in this driver,
--David Olix [MSFT]
BatchUpdateException
Hi,
Im having a problem with the SQL Server 2005 JDBC Driver v1.1, when it throws a BatchUpdateException it is not setting the vendor-specific error code! It is always returning zero for the error code. The exception is being thrown due to a Unique key contraint. It should be throwing the error codes ( 2627 or 2601 ) which were thrown by the SQl Server 2000 driver.
Can anyone explain?
Hi,
Let me research this and get back to you. It looks like it may be a bug in the 2005 driver. What driver version are you using (output from DatabaseMetaData.getDriverVersion())?
Thanks,
--David Olix (MSFT)
|||Hi David,
The driver version is 1.1.1501.101
Thanks again,
Cathal
|||
Ok, thanks. Two more questions for you then:
1. Does this behavior happen only when the key violation occurs on the first (or only) statement in the batch?
2. Are you seeing the behavior with Statement, but not PreparedStatement or CallableStatement?
If the answer is 'yes' to both of these then I believe it's a bug that we are currently targetting to fix in the next JDBC driver release around mid-year.
If that's not the problem, then you may may want to contact Microsoft Customer Support (support.microsoft.com) for further assistance.
Thanks again,
--David Olix (MSFT)
|||Hi David,
Thanks again for your reply. Our tests can confirm the behaviour you have outlined above. Could you give me some more detail about this bug, a tracking number etc? Just so we can keep track of it from our end.
Thanks,
Cathal
|||Hi David,
Thank you for your help with this issue. Would you be able to confirm my previous request for a bug tracking number for this issue. We are keeping track of it from our end and would like to close this issue as soon as possible.
Thanks again,
Cathal
|||Hi Cathal,
Sorry for not catching your previous post. I'm not quite sure what kind of tracking number you are requesting. We don't maintain a bug database for public reference. Would an internal bug tracking number help you any? Alternately, if you open a support case with Customer Support (support.microsoft.com), they will provide you with a case number that you can use for tracking. They may also be able to provide you with an unsupported interim build that contains the fix for development and testing purposes -- not for production. The fix will also be in the publicly available v1.2 CTP1, currently targeted for April.
Thanks again for your continued interest in this driver,
--David Olix [MSFT]
Batch updates with SQL CLR
Here's what I'm currently doing:
I have a C# stored procedure, using a context connection, that updates all the records in a table (typically a million records) by repeatedly:
- sequentially reading a group of records (1000 at a time) into a SqlDataAdapter (using a 'select top row_number' -type statement that prevents re-querying processed records);
- performing complex processing on each record and writing the results back to the adapter (several fields of each record are updated);
- updating the table when each group has been processed.
This works, but it's not quite as fast as I'd have hoped for and is only slightly slower if using a non-context connection from an external application. I'd like to enable batch updating to increase performance (I actually get much faster performance from an external application that batch updates using a non-context connection, say 20% faster!)... but of course I can't with SQL CLR.
Any ideas on how I can improve performance of my updating?
Thanks in advance,
Graham
If I understand correctly, you're doing record by record calculation. So all required info is present within the record. If I would try to solve this I would have started with a CLR function, not a SP. So my statement would look something like:
Update BigTable Set CalcField = CLRFunc.ToughCalc(fieldX, fieldY, fieldZ)
I'm not sure if this would be faster, but it would be set based (not all functions will produce set bases solutions)
2012年2月11日星期六
Basic SQL server setup questions...
I'm setting up a database for the company I work for. Should I setup a different database for each division in our company (e.g. accounting, project management, estimating, etc.), or should I use just one database? It seems like it would be easier to use one database so I only have to use one connection, but is this ideal? I want all the info from the different divisions to be used together, but at this point I'm confused as to how to connect different databases together, if I were to go this way.
Thanks for any input or ideas!I create seperate databases based on the app function - not the company division.
many times you'll get people from different functional areas all using the same apps...
anyways, you can get to all the data in a single db with a single connection if its all on the same server. you just need to qualify the table names in your queries with a prefix of the database name.
i.e.
AccountingDB.dbo.table.column
since this is a pain to type, in one of our dbs that shared a user table with an existing db, we created a view that pulled all users from the other db. now our new database has a local view that we can treat like a user table...one connection can pull data from 2 (or more) databases :-)
2012年2月9日星期四
Basic replication problem
setting replication up can be so hard!
I'm setting up transactional replication, SQL 2000. I want to replicate a
whole database but for the moment i'm trying to get it working with one
table (or any combination of tables!). I've chosen push subscription.
The snapshot agent runs ok, generating a snapshot of all the required
articles. When i start the distribution agent to push out the subscription i
always get an error. I think its because of the settings in table article
properties (what to do 'If a table named xxx exists at the Subscriber').
But no matter what i do there is always a problem. If i say keep the
existing data unchanged then i get a duplicate primary key error (why does
it try to re-insert the rows again?). If i get rid of the existing data in
whatever way it doesnt work because of referential integrity rules. I tried
doing all tables at once (all the tables that have constraints between one
another) but that has no effect.
All i want to do is update the table(s) with any changes... can't be that
hard surely?
Paul
Paul Ibison wrote:
> Paul,
> leaving the table as it is can be used if you are
> replicating to a different tablename. As far as I can tell
> for your requirements, you should choose to drop the
> existing table (if you really want to leave the table
> there as it has the same data as the publisher, then try a
> nosync initialization.)
> HTH,
> Paul Ibison
Thanks Paul, I seem to have got it working now anyway... and after messing
about with this for 2 days an hour after i posted this message.. typical!
I changed the article snapshot setting to "delete data in the existing table
that matches the row filter statement" and that has done the trick. I
expected to have to type in SQL to select all the rows in the table but i
didn't have to. So what filter statement its using i have no idea! But it
works anyway!!