Overcome 255 Character Limit In String When Importing From Database (SQL)

anselhelm

New Member
Joined
Feb 28, 2016
Messages
4
Hi everyone,

I'm having troubles resolving a problem with a spreadsheet that pulls records data out of a data via SQL.

The original functionality was set up by someone else and I've unofficially inherited its running and improvement, as that person is no longer around.

The spreadsheet uses the SQL Select statement to pull information out of the database where it matches one of two fields (depending on what the user searches for).

The problem is that one of the fields ("Aliases") is in "Long Text" format as I needed more space than 255 characters for it. On importing, everything after 255 characters is truncated.

I've spent hours reading up on others' workarounds for their specific issues, but alas I cannot work out how their solutions work to apply it to my own.

Basically, I'd appreciate any specific help with someone explaining in very simple terms how to work around the character import limit in my specific scenario.

If the code below doesn't make sense, it might be because there are some functions listed in Public Subs. If you need me to put the code for these too, please LMK.

I've copied in just part of the code that forms the Select statement. I can include more of the code from this Sub too if I've not included enough.

Code:
db.Connect

If imerchantname <> "" And imerchantID = "" Then
strSQL = "SELECT tblMerchantID.[Scheme], tblMerchantID.[Currency], tblMerchantID.[Merchant Name], tblMerchantID.[ICA (Clearing)], tblMerchantID.[Clearing ID], tblMerchantID.[ACQ BIN (Auth)], tblMerchantID.[Authorisation ID], tblMerchantID.[MCC], tblMerchantID.[Expected Frequency], tblMerchantID.[Aliases], tblMerchantID.[Country], tblMerchantID.[Date/Time Added], tblMerchantID.[Date/Time Updated] " & vbCrLf & _
"FROM tblMerchantID " & vbCrLf & _
"GROUP BY tblMerchantID.[Scheme], tblMerchantID.[Currency], tblMerchantID.[Merchant Name], tblMerchantID.[ICA (Clearing)], tblMerchantID.[Clearing ID], tblMerchantID.[ACQ BIN (Auth)], tblMerchantID.[Authorisation ID], tblMerchantID.[MCC], tblMerchantID.[Expected Frequency], tblMerchantID.[Aliases], tblMerchantID.[Country], tblMerchantID.[Date/Time Added], tblMerchantID.[Date/Time Updated] " & vbCrLf & _
"HAVING (((tblMerchantID.[Merchant Name]) Like ""*" & imerchantname & "*"") OR ((tblMerchantID.[Aliases]) Like ""*" & imerchantname & "*""));"
End If

If imerchantname = "" And imerchantID <> "" Then
strSQL = "SELECT tblMerchantID.[Scheme], tblMerchantID.[Currency], tblMerchantID.[Merchant Name], tblMerchantID.[ICA (Clearing)], tblMerchantID.[Clearing ID], tblMerchantID.[ACQ BIN (Auth)], tblMerchantID.[Authorisation ID], tblMerchantID.[MCC], tblMerchantID.[Expected Frequency], tblMerchantID.[Aliases], tblMerchantID.[Country], tblMerchantID.[Date/Time Added], tblMerchantID.[Date/Time Updated] " & vbCrLf & _
"FROM tblMerchantID " & vbCrLf & _
"GROUP BY tblMerchantID.[Scheme], tblMerchantID.[Currency], tblMerchantID.[Merchant Name], tblMerchantID.[ICA (Clearing)], tblMerchantID.[Clearing ID], tblMerchantID.[ACQ BIN (Auth)], tblMerchantID.[Authorisation ID], tblMerchantID.[MCC], tblMerchantID.[Expected Frequency], tblMerchantID.[Aliases], tblMerchantID.[Country], tblMerchantID.[Date/Time Added], tblMerchantID.[Date/Time Updated] " & vbCrLf & _
"HAVING (((tblMerchantID.[Clearing ID]) Like ""*" & imerchantID & "*"") OR ((tblMerchantID.[Authorisation ID]) Like ""*" & imerchantID & "*""));"
End If

db.RunGetResults (strSQL)
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Forum statistics

Threads
1,216,119
Messages
6,128,947
Members
449,480
Latest member
yesitisasport

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top