Joel Brown
asked on
SQL BCP Script
I'm using the following script and get an error saying " > was expected at this point" and I can't figure out what's wrong with it ... Variables are defined at the top of the batch file.
Thanks a million for any help ..
bcp "SELECT DISTINCT PM.vwGenPatInfo.Patient_La st_Name, PM.vwGenPatInfo.Patient_Fi rst_Name, PM.vwGenPatInfo.Patient_MI , PM.vwGenPatInfo.Patient_DO B, PM.vwGenPatInfo.Patient_Se x,
PM.vwGenPatInfo.Patient_St reet1, PM.vwGenPatInfo.Patient_St reet2,PM.v wGenPatInf o.Patient_ City, PM.vwGenPatInfo.Patient_St ate, PM.vwGenPatInfo.Patient_Zi p_Code,
PM.vwGenPatInfo.Patient_Ho me_Phone,P M.vwGenPat Info.Patie nt_SSN, PM.vwApptDetail.Appointmen t_DateTime FROM %DBNAME%.PM.vwApptDetail INNER JOIN %DBNAME%.PM.vwGenPatInfo ON
PM.vwApptDetail.Patient_Nu mber = PM.vwGenPatInfo.Patient_Nu mber
WHERE (%DBNAME%.PM.vwApptDetail. Appointmen t_DateTime BETWEEN CONVERT(date, DATEADD(day, 1, GETDATE())) AND CONVERT(date, DATEADD(day, 4, GETDATE()))) AND (%DBNAME
%.PM.vwApptDetail.Status <> 'X') AND (%DBNAME%.PM.vwApptDetail. Patient_Nu mber <> '300780')" queryout %CSVPATH%\appt.csv -S%SERVERNAME% -c -t^| -U%SQLLOGIN% -P%SQLPASSWORD%
Thanks a million for any help ..
bcp "SELECT DISTINCT PM.vwGenPatInfo.Patient_La
PM.vwGenPatInfo.Patient_St
PM.vwGenPatInfo.Patient_Ho
PM.vwApptDetail.Patient_Nu
WHERE (%DBNAME%.PM.vwApptDetail.
%.PM.vwApptDetail.Status <> 'X') AND (%DBNAME%.PM.vwApptDetail.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Make sure your bcp command is on one line entirely. Also you can use != instead <>, just in case:
bcp "SELECT DISTINCT PM.vwGenPatInfo.Patient_Last_Name, PM.vwGenPatInfo.Patient_First_Name, PM.vwGenPatInfo.Patient_MI, PM.vwGenPatInfo.Patient_DOB, PM.vwGenPatInfo.Patient_Sex, PM.vwGenPatInfo.Patient_Street1, PM.vwGenPatInfo.Patient_Street2,PM.vwGenPatInfo.Patient_City, PM.vwGenPatInfo.Patient_State, PM.vwGenPatInfo.Patient_Zip_Code, PM.vwGenPatInfo.Patient_Home_Phone,PM.vwGenPatInfo.Patient_SSN, PM.vwApptDetail.Appointment_DateTime FROM %DBNAME%.PM.vwApptDetail INNER JOIN %DBNAME%.PM.vwGenPatInfo ON PM.vwApptDetail.Patient_Number = PM.vwGenPatInfo.Patient_Number WHERE (%DBNAME%.PM.vwApptDetail.Appointment_DateTime BETWEEN CONVERT(date, DATEADD(day, 1, GETDATE())) AND CONVERT(date, DATEADD(day, 4, GETDATE()))) AND (%DBNAME%.PM.vwApptDetail.Status <> 'X') AND (%DBNAME%.PM.vwApptDetail.Patient_Number != '300780')" queryout %CSVPATH%\appt.csv -S%SERVERNAME% -c -t^| -U%SQLLOGIN% -P%SQLPASSWORD%
Open in new window