Re: Validations in bcp format file



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
.



Relevant Pages

  • Re: Binary_Checksum - How secure is it?
    ... in an encrypted format and a different column has the original value in ... For example, if 'abc' is a password, its first encrypted and put in ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (microsoft.public.sqlserver.security)
  • Re: replacing substring within string
    ... -- hello abc world abc yo hello 123 world 123 yo ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: Query training -- Complex queries
    ... > Update PositionsEOM ... Here you don't have a derived table, but a correlated subquery. ... UPDATE in Books Online. ... is not written for SQL Server. ...
    (microsoft.public.sqlserver.server)
  • Re: Linked Server: How to check if server exists?
    ... The root problem is described in the Books Online topic Batches. ... Rick Byham, SQL Server Books Online ... linked server don't run on those development machines not having that linked ...
    (microsoft.public.sqlserver.connect)
  • Re: STORED PROCEDURE - passing table name as a parameter
    ... T-SQL, is that you get problems if the view definition does not fit into ... will need to query other system tables, for instance syscolumns. ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)