Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 difficulty using bcp

Author  Topic 

rtutus
Aged Yak Warrior

522 Posts

Posted - 2006-12-25 : 17:24:54
I use this in a new query script in SSMS:
use dbtest1
bcp mycsvtable1 in 'C:\myDev\SQL\CSVproject\myCSV.txt' -T -c

but i get the error:

Msg 102, Level 15, State 1, Line 2
Incorrect syntax near 'bcp'.


I also tried:
myDatabase.dbo.mycsvtable1 and I got the same error
any help pls?

madhuotp
Yak Posting Veteran

78 Posts

Posted - 2006-12-26 : 01:44:54
u must run BCP from Command Prompt or using XP_cmdshell


Madhu



Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-12-26 : 11:31:30
If you are importing data, you can also use the BULK INSERT command. The options are very similar to BCP. You can find the exact syntax in SQL Server Books Online.




CODO ERGO SUM
Go to Top of Page

rtutus
Aged Yak Warrior

522 Posts

Posted - 2006-12-26 : 12:52:28
in cmd shell. i guess i should use:
bcp myDatabase.Owner.myTable .....
1/how do i know who the owner of the table is? i mean if it s dbo or other?any command or something like that?
2/ and will i have to include the sql instance name as well in the command?
Thanks a lot.
Go to Top of Page

madhuotp
Yak Posting Veteran

78 Posts

Posted - 2006-12-26 : 23:30:27

You have to mention Database.Schema.ObjectName in BCP. If these are to be dynamic, then you have to use XP_CmdShell and Dynamic SQL

quote:
Originally posted by rtutus


2/ and will i have to include the sql instance name as well in the command?




To connect to a particular Instance u have to mention -S option in BCP command.

Madhu
Go to Top of Page
   

- Advertisement -