Re: how to create a string of values that can be used to insert in SQL server by AA
AA
Fri Oct 20 04:00:33 CDT 2006
SELECT sourcecursor
SCAN
TEXT TO lcSQL TEXTMERGE NOSHOW
INSERT INTO SQLServerTable VALUES ('<<TRIM(sourcecursor.field1)>>',
[<<sourcecursor.field2>>],
<<DTOC(sourcecursor.datefield)>>,
<<sourcecursor.field4>>)
ENDTEXT
DEBUGOUT M.lcSQL
n=SQLEXEC(M.connhandle, M.lcSQL)
IF M.n<0
* error handling
ENDSCAN
You can also send variables or cursor fieldnames
SCAN
SQLEXEC(connhandle, [INSERT INTO Target VALUES
(?sourcecursor.field1,?sourcecursor.field2,?sourcecursor.datefield)] )
ENDSCAN
or replace the direct references with variables.
TEXT - ENDTEXT is a convenient way to build lengthy and complex commands
strings into a variable.
-Anders
"Rajesh" <rajeshhalyal@gmail.com> skrev i meddelandet
news:1161314969.786658.105460@i42g2000cwa.googlegroups.com...
>I am trying to create a string depending on the cursor fields & its
> type to be used to pass it to insert command for SQL server.
> I am having 2 problems
> 1> How to include character fields with quotes, square brackets & other
> special characters.
> 2> How to send date fields.
>
> Rajesh
>