Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 12th, 2003, 03:59 AM
Authorized User
 
Join Date: Sep 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to devrishi
Default Using bcp Utility in SQL

hi,

When we use bcp over SQL Data to transfer data to text file, it is giving me Date in Reverse order (Year-Month-Date). Visual Foxpro finds it difficult to convert it into date field.

Is there any way out to convert the date or any other way I can use 'bcp utility' so that it gives me Dates in dd/mm/yyyy format.

Please help. Its urgent.

Regards

Devrishi

 
Old November 13th, 2003, 03:01 AM
Registered User
 
Join Date: Nov 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

How about converting the date field within the query? Something like this should work:

Code:
SELECT *, CONVERT(CHAR(10), DateField, 103) FROM tblTable
Cheers,
Brendan.

 
Old November 13th, 2003, 05:07 AM
Authorized User
 
Join Date: Sep 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to devrishi
Default

hi Brendan,

thanks for ur help. It works. but I'm using bcp (bulk copy) utility. Is there any way in which I can convert datetime field in bcp?


Regards

Devrishi

 
Old November 24th, 2004, 03:43 AM
Registered User
 
Join Date: Nov 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Devrishi

What Brendan means (I believe) is to use the queryout flag in BCP.

Ie. BCP "SELECT TOP 10 * FROM Pubs..tblTable" queryout -c -E -Usa -Ppassword -SServername

Substitute the SQL for whatever you want (function or not) to get the format you desire.

Hope this helps.

Gary


 
Old November 24th, 2004, 03:47 AM
Registered User
 
Join Date: Nov 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Oops.

Missed out the target text File.

How about this instead.

Ie. BCP "SELECT *, CONVERT(CHAR(10), DateField, 103) FROM tblTable" queryout Text.txt -c -E -Usa -Ppassword -SServername

Gary






Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Query output to XML using BCP HELP!! miamikk SQL Language 3 May 15th, 2009 08:22 AM
Alternative of BCP Utility to update Database rajnikantbal C# 3 January 16th, 2008 12:46 PM
txt file generated from SQl BCP nidhigarg9 SQL Server 2000 1 June 16th, 2006 02:16 PM
Cool utility Yurko SQL Server 2000 3 December 2nd, 2005 11:03 AM
Bcp utility jejyjose SQL Server 2000 1 October 16th, 2003 08:31 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.