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
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 bcp to CSV file question

Author  Topic 

robert693
Starting Member

42 Posts

Posted - 2010-11-15 : 11:12:47
Hello,

I am running a bcp command out of a SQL Database and dumping the data in a CSV file. I am then trying to upload the data to the Calendar in MS Outlook. I go through the Import and Export Wizard in Outlook to upload the data. I choose Import from another file ?Comma Separated Values(Windows) and then I get an error message that says that there was an error in the comma separated values(windows) translator while initializing a translator to build a field map. I have exported the calendar out of Outlook to a CSV file and copied and pasted the field names in the Outlook csv file to the bcp csv file. When I did this the file is imported to Outlook just fine. I have also copied the field names from the Outlook csv file, into the bcp command and it sill produces a csv file that will not upload into Outlook. Is there something that I am missing? Here is the bcp command:

BCP "SELECT 'Subject', 'Start Date', 'Start Time', 'End Date', 'End Time', 'All day event', 'Reminder on/off', 'Reminder Date', 'Reminder Time', 'Meeting Organizer', 'Required Attendees', 'Optional Attendees', 'Meeting Resources', 'Billing Information', 'Categories', 'Description', 'Location', 'Mileage', 'Priority', 'Private', 'Sensitivity', 'Show time as' UNION ALL SELECT [CPT].[Short_Desc]+' '+[vw_Schedule].[Notes], CONVERT(CHAR(8), [vw_Schedule].[App_DtTm],1), CONVERT(CHAR(8), [vw_Schedule].[App_DtTm],8), CONVERT(CHAR(8), [vw_Schedule].[App_DtTm],1), CONVERT(varchar(8),DATEADD(n,([vw_Schedule].[Duration_time]/6000),DATEADD(dd,-DATEDIFF(dd,0,[vw_Schedule].[App_DtTm]),[vw_Schedule].[App_DtTm])),108), 'FALSE' as [All day event], 'FALSE' as [Reminder on/off], CONVERT(CHAR(8), [vw_Schedule].[App_DtTm],1), CONVERT(CHAR(8), [vw_Schedule].[App_DtTm],8), [vw_Schedule].[STF_INITIALS], '' as [Required Attendees], '' as [Optional Attendees], '' as [Meeting Resources], '' as [Billing Information], '' as [Categories], [vw_Schedule].[Activity], [vw_Schedule].[LOC_INITIALS], '' as [Mileage], '' as [Priority], '' as [Private], '' as [Sensitivity], '' as [Show time as] FROM [MOSAIQ].[dbo].[vw_Schedule] [vw_Schedule] LEFT OUTER JOIN [MOSAIQ].[dbo].[CPT] [CPT] ON [vw_Schedule].[Activity]=[CPT].[Hsp_Code] WHERE [vw_Schedule].[STF_INITIALS] <> '' and CONVERT( Varchar(12), [vw_Schedule].[App_DtTm],1) = CONVERT( Varchar(12), GetDate(),1) AND ([vw_Schedule].[Activity]='CONSULT' OR [vw_Schedule].[Activity]='MTG' OR [vw_Schedule].[Activity]='VAC')" queryout C:\Scheduletext.csv -c -t, -SMosaiqreports -T

robert693
Starting Member

42 Posts

Posted - 2010-11-15 : 16:02:04
Hello, I noticed that the file that was dounloaded from Outlook has quotations around all of the titles (i.e. Subject is "Subject") when it is opened in Notepad. The file exported from the SQL Server DB does not have them. How can I put the quotes in the titles above?
Go to Top of Page
   

- Advertisement -