Break it into pieces and put them back together and run the string:
tsql1 = "SELECT fieldlist"
tsql2 = "more fields"
tfrom = "FROM ...."
twhere = "WHERE ...."
torder = "ORDER..."
tinto = "INTO ..."
tsql = m.tsql1 + m.tsql2 + m.tfrom + m.twhere + m.torder + m.tinto
&tsql
NOTE: No one line can be longer than 254 characters, but the combined length of of the mvars into tsql is unlimited.
BTW: In your example it should read DTOS(bs_arch.mail_date) >= '19981201' if bs_arch.mail_date is a date field.
>What's the best way to parse a long SQL statement into a string variable?
>
>For example:
>
>cquery = "select mastddup.location, mastddup.census, ;
>mastddup.name,mastddup.addr1, mastddup.city, mastddup.state, mastddup.zip,;
>mastddup.zip4,bs_arch.location, bs_arch.mail_date,bs_arch.mail_code from mastddup,;
>bs_arch where mastddup.location=bs_arch.location and bs_arch.mail_date >= '19981201' "
>
>The problem I've got with this particular string is the last "and" clause. I keep getting syntax errors.