BCP derived fields

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dipu vp
    New Member
    • Sep 2007
    • 2

    BCP derived fields

    thanx in advance.....

    Pls suggest an idea to import derived fields from the data file to SQLServer2005 using the BCP utility?

    eg: in the data file there are

    Location UserLocId
    USA 1
    USA 2
    IND 1
    IND 2

    I have to import Unique usercode like
    'USA_1'
    'USA_2'
    'IND_1'
    'IND_2'

    If there is any way to upload this using BCP
    ( updating the usercode after loading will take more time)
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    As you have posted a question in the articles section it is being moved to SQL Server Forum.

    MODERATOR.

    Comment

    • ck9663
      Recognized Expert Specialist
      • Jun 2007
      • 2878

      #3
      Originally posted by dipu vp
      thanx in advance.....

      Pls suggest an idea to import derived fields from the data file to SQLServer2005 using the BCP utility?

      eg: in the data file there are

      Location UserLocId
      USA 1
      USA 2
      IND 1
      IND 2

      I have to import Unique usercode like
      'USA_1'
      'USA_2'
      'IND_1'
      'IND_2'

      If there is any way to upload this using BCP
      ( updating the usercode after loading will take more time)
      i have not tried this, but here's an idea:

      i think you can BCP into an existing table. so your FMT (format file) could be different from that of the existing table structure. can you try to have an format file based on Location, UserLocId structure and have an existing table with an extra calculated filed called UserCode with default value rtrim(Location) + '_' + ltrim(UserLocId )

      i don't know if it will work but worth a shot.

      Comment

      Working...