2012年3月8日星期四
bcp file format...its killing me...pleaseeeeeeeee help...
i wanted to ask on the same context of bcp...i m trying to insert two rows into a table using the bcp command prompt and the bcp file looks as follow(format.fmt):
7.0
3
1 SQLCHAR 0 4 "\"," 1 numbers
2 SQLCHAR 0 15 "\"" 2 values
3 SQLCHAR 0 2 "\r\n" 3 finish
and the input file has the following contents
1234,"other"
5678,"column"
now when i m running the command as
bcp master.dbo.two_column in c:\temp\input.txt -fc:\temp\format.fmt -Sserver -Uuser -Ppasword -T
it gives me the error as sqlstate 07009 with native state =0 and the error as = [Microsoft][SQL Native Client] Invalid descriptor index
i m using sql server 2005 (YUKON)...can anyone pleaseeeeeeeeeeeeee tell me how can i solve this problem???????so that i can insert these rows into my table two_column...
thanks ...pleaseeeeeeeeee help me...First off, line one should not be 7.0 for 2005.
For SQL 2k it.s8.0
I guess 2005, it should be 9.0, but I don't know that for sure.
Did you get the 2005 BOL Beta as well?|||Just curious, but what's the DDL for creating your table? I suspect it only has two columns.
-PatP|||Thanks for your replies...but now...i have changed the version of format file as follow...n yeah i have 2columns only:
9.0
2
1 SQLCHAR 0 4 "," 1 in_numbers SQL_Latin1_General_CP1_CI_AS
2 SQLCHAR 0 5 "\r\n" 2 values SQL_Latin1_General_CP1_CI_AS
and the input file is
1234,other
5678,column
but now its givin me the error as I\O error while reading BCP format file...
it was workin for sometime..it copied these two rows as well...but again its givin me this error again n again...i cant understand...wat m i suppose to do now...PLEASEEEEE TRY TO HELPPPP
thnks in advance|||Can you post the exact error ?|||hi,
the error was just that I\O error while reading the BCP file format...but now finally its over since i had to press enter twice...after the last row in the format file...just some empty rows in the format files had solved my problem
thnks.
2012年2月16日星期四
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)