Hi,
On SQLServer 2000, I have a table with a following structure:
MYTABLE
col1 char,
col2 date,
col3 number
My Objective:
------------
Externally (from a command line), to select all columns and write the
output into a file delimited by a comma.
My method:
---------
1. Probably will use OSQL or BCP to do this.
2. Use the following syntax:
select RTRIM(col1) +','+ RTRIM(col2) +','+ RTRIM(col3)
from MYTABLE;
My 3 Problems:
-------------
1) If there is a NULL column, the result of concatenating any value with
NULL, is NULL. How can I work around this? I still want to record this
column as null. Something like say from the example above, if col2 is
null, would result to: APPLE,,5
2) The time format when querying the database is: 2003-06-24 15:10:20.
However, on the file, the data becomes: 24 JUN 2003 3:10PM. How can I
preserve the YYYY-MM-DD HH:MM:SS format? Notice that I also lost the
SS.
3) Which utility is better? BCP or OSQL?
For OSQL, it has a "-s" flag which gives me the option of putting a
column separator. But the result is:
"APPLE ,14 JUN 2003 , 5"
I don't need the extra space.
While for BCP, there is no column separator flag.
You will notice from my inquiry above that my background in SQLServer is
not very good.
Thanks in Advance!!
Regards
Ricky
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!