Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 BCP or a Stored Procedure to check length of file

Author  Topic 

Michael71
Posting Yak Master

126 Posts

Posted - 2007-01-17 : 09:50:04
How can I get BCP or a Stored Procedure to check the first line in the file(flat file)of the data it is tranfering over, to see if it is the correct file. I want it to look for the first line of 624 or 625 characters (it must allow for an extra carraige return character under windows)The data that comes in from a company, hits a different server within the same building.

Please help

nr
SQLTeam MVY

12543 Posts

Posted - 2007-01-17 : 15:59:49
You should have that info in the filename.

You can do a bulk insert and set the lastrow parameter to 1.
Bulk insert into a single column temp table with 0x00 or something not in the file as the column delimiter - this will work as long as the row delimiter is in the file (if not you will get an error and I guess you know the file is not the one you want. You can then check the row in the temp table.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -