FoxPro Programming
Retrieve data from nVarchar(max)
Gravatar is a globally recognized avatar based on your email address. Retrieve data from nVarchar(max)
  Bob
  All
  Jun 24, 2022 @ 08:35am

I am trying to retrieve data from an Sql table nvarchar(max) field using the Foxpro SQl Exec. This is the code

Declare @medcustnum nvarchar(5) = '07339'
Declare @medtype nvarchar(2) = 'CL'
 SELECT ProbNotes from Medical
Where MedCustNum =  @medcustnum and MedType=@medtype 
*sql_text = above text
SQLExec(Sql_Handle,sql_text,"MedMemo",aCount)

If I am retrieving from an nvarchar(100) field this type of code works fine and returns the correct value. however if retrieving from an nvarchar(max) field, the result always comes back blank. Any Suggestions?

Gravatar is a globally recognized avatar based on your email address. re: Retrieve data from nVarchar(max)
  Rick Strahl
  Bob
  Jun 24, 2022 @ 08:52am

Several things you can do:

  • Cast your SQL Queries to a specific length
  • Use a different SQL Server driver

The latter is a problem as the various ODBC drivers have different support for different features and none of them really do a good job with all the features. You can search this forum for a discussion on this topic some time ago and there were some suggestions for which drivers work best for which scenarios.

I tend to use the original SQL Server driver (ie. don't specify) and that seems to work with varchar(max).

+++ Rick ---

© 1996-2024