Re: Validations in bcp format file
- From: Erland Sommarskog <esquel@xxxxxxxxxxxxx>
- Date: Thu, 25 May 2006 12:49:14 +0000 (UTC)
Veeru (Veeru@xxxxxxxxxxxxxxxxxxxxxxxxx) writes:
The validations like
1. if the datafile field data is "ABC" I want to insert the data into
table as "DEF" or if the datafile field data is "123" I want to insert
the data into table as "456" .
In the format file, no. But SQL 2005 has a new rowset provider BULK,
so that you can say:
SELECT CASE field WHEN 'ABC' THEN 'DEF'
WHEN '123' THEN '456'
END
FROM OPENROWSET(BULK, ...)
Please check Books Online for exact syntax.
2. Format the date filed and insert the formated date data into table
column.
Again, use the rowset proivder.
3. Assign default values or Constant values for the columns of the table,
the data for those fields are not exist in the date file
This is doable without the rowset provider. You need to alter the table
to set up the proper default values.
The format file itself only describes the format of the the input
and nothing more.
--
Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
.
- Prev by Date: Re: BCP/OSQL
- Next by Date: Re: USAGE OF DECODE STATEMENT IN FORMAT FILE OF BCP UTILITY
- Previous by thread: Re: table
- Next by thread: Re: USAGE OF DECODE STATEMENT IN FORMAT FILE OF BCP UTILITY
- Index(es):
Relevant Pages
|