Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Merge Two Memo fields from two different VFP tables with ODBC

Status
Not open for further replies.

lchan

Programmer
Feb 2, 2011
1
US
I tried to merge two memo fields via ODBC but the length of the string is more than 255 characters. Is there any way to get around it? I can also do it in native VFP, but don't know how. Any suggestion?

Thanks.

Happy Chinese New Year
 
You say that these are VFP tables. If that's right, you shouldn't be using ODBC. You can do it very easily with simple VFP commands.

Also, what do you mean by "merge"? How do you want to combine the two fields?

If you simply want to concatenate two memo fields into a third memo field, the following should work:

Code:
SELECT Table3
REPLACE Memo3 WITH Table1.Memo1 + Table2.Memo2

This code will concatenate the contents of Memo1 in Table1 with Memo2 in Table2, and put the result in Memo3 in Table3. You shouldn't get any truncation of 254 characters if you define Memo3 as a memo field rather than a character field.

If this doesn't answer your question, could you please clarify what you are trying to achieve.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Ah, it occurs to me that you are using ODBC because you are trying to do this operation from outside of VFP. Is that correct?

If so, you are probably using a SQL SELECT statement, something like this:

Code:
SELECT Memo1 + Memo2 AS Memo3 FROM ....

If that's right, then you could well see Memo3 being truncated to 254 characters.

The solution is to use a CAST() construct:

Code:
SELECT [b]CAST([/b]Memo1 + Memo2 [b]AS M)[/b] AS Memo3 FROM ....

But keep in mind that the above syntax is specific to VFP. It won't necessarily work with other back ends.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top