Results 1 to 3 of 3

Thread: Reg: BCP

  1. #1
    Join Date
    Sep 2008
    Posts
    40

    Unanswered: Reg: BCP

    Hi ,
    I have added a column with data type as date in table with default value as getdate(). i need to populate data from someother table say X with that default column less.
    is there any way to populate using BCP
    eg:

    create table X
    {
    name varchar(10),
    id numeric(5)
    }

    create table Y
    {
    name varchar(10),
    id numeric(5),
    date date default(getdate())
    }

    i need to populate data from X to Y is there any way to do using BCP utility.

    }

  2. #2
    Join Date
    Jan 2004
    Posts
    545
    Provided Answers: 4
    You want the data from X in Y, plus populate the column 'date'? You can do that without BCP too:

    insert into Y(name, id)
    select name, id from X
    I'm not crazy, I'm an aeroplane!

  3. #3
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    Use a format file e.g.
    Code:
    bcp tempdb..x out t1.txt -UPD
    Password: 
    
    Enter the file storage type of field name [char]: 
    Enter prefix-length of field name [0]: 
    Enter length of field name [30]: 
    Enter field terminator [none]: \t
    
    Enter the file storage type of field id [int]: char
    Enter prefix-length of field id [1]: 0
    Enter length of field id [12]: 
    Enter field terminator [none]: \n
    
    Do you want to save this format information in a file? [Y/n] y
    
    Host filename [bcp.fmt]: t1.fmt
    
    Starting copy...
    
    6 rows copied.
    Clock Time (ms.): total = 1  Avg = 0 (6000.00 rows per sec.)
    
    bcp tempdb..y in t1.txt -UPD -f t1.fmt
    Password: 
    
    Starting copy...
    
    6 rows copied.
    Clock Time (ms.): total = 1  Avg = 0 (6000.00 rows per sec.)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •