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

2012年3月11日星期日

bcp in child before parent

Huh?

I've got good RI data...BUT..a developer loaded the tables in alpha table order...

Such that the child loaded BEFORE the parent...

Huh?

Got a test being set up now to mess with the child file to add a key that doesn't exist in the parent...

But Why is this allowed?

In DB2 you can specify

LOAD DATA REPLACE NO CHECK...

On the load card...you then need to run a check after to verify the data...

Is that what's going on? Is there such a utility in SQL Server to run a check post load?

I'm confused...

Any comments appreciated.

Thanks

Brett

8-)OK, -h option would allow you to check constraints

Otherwise it doesn't

So then if you use the default, How do you make sure the data is ok?|||d'oye....

DBCC CHECKCONSTRAINTS

What a maroon....

2012年3月6日星期二

BCp ERROR?

Getting the following error when loading txt file to a table
All rows appear to be loaded

What can be done to avoid this error?

Microsoft][ODBC SQL Server Driver]Unexpected EOF encountered in BCP data-file

bcp "table" in "textfile" -f"Format.fmt" -e"error.txt" -SServername -Tis that the entire contents of the error.txt file? Usually the error file will tell you what row/column had the problem.

2012年2月23日星期四

bcp and order of rows in table

I am loading data from external program using bcp into a temp table.
I assumed that the rows would be loaded sequentially (same order as
file). Is there a option or some other method to load the data in the
same order as the records in the file. Here is what I'm trying to do:
SET @.C='bcp ##tkaladt in ' + @.dir + @.file + ' -f
e:\kaleida\smsadtimp.fmt -U bla -P blabla'
EXEC @.R = master.dbo.xp_cmdshell @.C
DECLARE c_adtrecs CURSOR
for
select * from ##tkaladt
process records in the order they are in the file.
A table is, per definition, not ordered. How about adding an identity column, letting SQL Server generate the
identity values as BCP inserts the rows and use that column in your SELECT statement's ORDER BY?
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
"Joe R" <jralabate@.kaleidahealth.org> wrote in message news:eQE13hGLEHA.2660@.TK2MSFTNGP09.phx.gbl...
> I am loading data from external program using bcp into a temp table.
> I assumed that the rows would be loaded sequentially (same order as
> file). Is there a option or some other method to load the data in the
> same order as the records in the file. Here is what I'm trying to do:
> SET @.C='bcp ##tkaladt in ' + @.dir + @.file + ' -f
> e:\kaleida\smsadtimp.fmt -U bla -P blabla'
>
> EXEC @.R = master.dbo.xp_cmdshell @.C
> DECLARE c_adtrecs CURSOR
> for
> select * from ##tkaladt
> process records in the order they are in the file.
>