Professional Web Applications Themes

bcp help - Microsoft SQL / MS SQL Server

Hello all, I am trying to create a sproc utilizing bcp, where I can dynamically name the files I want to output here is what I have written so far. SET QUOTED_IDENTIFIER off declare fileName as varchar(200) set fileName= 'bob' set fileName="'"+'bcp northwind..categories out c:\'+ fileName + '.bcp -S -U -P -c '+"'" select fileName master..xp_cmdshell fileName But I am getting this error message. Server: Msg 170, Level 15, State 1, Line 9 Line 9: Incorrect syntax near '.'. Can anyone help? Thank you...

  1. #1

    Default bcp help

    Hello all,

    I am trying to create a sproc utilizing bcp, where I can dynamically name
    the files I want to output

    here is what I have written so far.

    SET QUOTED_IDENTIFIER off

    declare fileName as varchar(200)
    set fileName= 'bob'
    set fileName="'"+'bcp northwind..categories out c:\'+ fileName +
    '.bcp -S -U -P -c '+"'"

    select fileName

    master..xp_cmdshell fileName


    But I am getting this error message.

    Server: Msg 170, Level 15, State 1, Line 9
    Line 9: Incorrect syntax near '.'.

    Can anyone help?
    Thank you





    Tkim Guest

  2. #2

    Default BCP help

    All I have is a DAT file to use. I am wondering if it is
    possible to use BCP to import this DAT file's contents
    into a database table. I am trying to use a command
    statement similar to what is shown below.

    bcp MyDatabase.dbo.color in data\color.dat -S MyServer -U
    sa -P blah

    Basically, I've been tasked with importing xml data into
    a database, and these DAT files are the only form of a
    schema I have. Will Sql allow me to use BCP and import
    data without using a format file? Will it just default to
    how it translates the DAT files? Can anyone provide me
    with an example?

    My system is XP Pro, using Sql 2000.

    Thanks for the help.

    Alex
    Alex Guest

  3. #3

    Default BCP help

    if your 'dat' file is a simple ascii file - you can use
    the bcp utility. Just add the -c and -t<terminator> flags

     

    to 
    ding Guest

  4. #4

    Default Re: BCP help

    You can use the BCP utility ... I think if its a simple DAT file then you
    can resort to using the Bulk Insert command ... Its simpler in usage ...
    Look at :
    http://www.extremeexperts.com/sql/articles/SimpleBulkInsert.aspx
    for a simple example ...

    --
    HTH,
    Vinod Kumar
    MCSE, DBA, MCAD
    www.extremeexperts.com


    "Alex" <com> wrote in message
    news:035401c36764$f71c8da0$gbl... 


    Vinodk Guest

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139