Hi,
I need make a scheduling job for bcp export data from databases' table to a
text file with column name. Does anyone know any method I can use?
Regards!
-ChenFirst I would try to create a stored procedure that uses xp_cmdshell to
execute a BCP? You could also create a linked server to an ODBC driver
for text, and insert records into that from a stored procedure. Either
method could then be scheduled. I'm sure there are other ways too.
You didn't mention which SQL Server you have, but I'm sure there is a
DTS solution and / or an Integration solution. Pick your poison!
Good luck...
-Rick|||Chen,
May be using osql.exe
Example:
c:\>osql -S(local) -E -Q"select orderid from northwind.dbo.orders"
-o"c:\temp\test.txt
AMB
"Chen" wrote:
> Hi,
> I need make a scheduling job for bcp export data from databases' table to
a
> text file with column name. Does anyone know any method I can use?
> Regards!
> -Chen
2012年3月20日星期二
BCP Out Command
I'm using the BCP OUT command to extract the contents of a SQL table to a
text file. When doing this is there an parameter to format the data into a
fixed format?
Script being used:
bcp.exe databasename.dbo.table OUT datafile -t
"," -c -CRAW -Sservername -Uuser -Ppassword
ThanksBrent Stevenson (essexbs@.insightbb.com) writes:
> I'm using the BCP OUT command to extract the contents of a SQL table to a
> text file. When doing this is there an parameter to format the data into a
> fixed format?
> Script being used:
> bcp.exe databasename.dbo.table OUT datafile -t
> "," -c -CRAW -Sservername -Uuser -Ppassword
Do you mean a format where each column has a fixed length? You would need to
use a format file for that.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspxsql
text file. When doing this is there an parameter to format the data into a
fixed format?
Script being used:
bcp.exe databasename.dbo.table OUT datafile -t
"," -c -CRAW -Sservername -Uuser -Ppassword
ThanksBrent Stevenson (essexbs@.insightbb.com) writes:
> I'm using the BCP OUT command to extract the contents of a SQL table to a
> text file. When doing this is there an parameter to format the data into a
> fixed format?
> Script being used:
> bcp.exe databasename.dbo.table OUT datafile -t
> "," -c -CRAW -Sservername -Uuser -Ppassword
Do you mean a format where each column has a fixed length? You would need to
use a format file for that.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspxsql
订阅:
博文 (Atom)