简体   繁体   中英

The token specified is too long. The maximum length is 128 characters

I am creating a data integration tool in C# that will move data from one database then to an intermediary then to the final, I am storing the required Database queries in a SQL CE database, on attempting to insert one of the queries into a table I receive:

Major Error 0x80040E14, Minor Error 25508 "Myquery" The token specified is too long. The maximum length is 128 characters. [ Maximum size of token (if known) = 128,Token(if known) = "Some of my query"

Query:

update SqlQueries Set Query = "CREATE TABLE [dbo].[ASI_SYBranch](
BranchName char(255),
BranchLogoName char(255),
NoteText TEXT,
BranchID char(30),
Active bit,
CoLocationName char(255),
City char(50),
Country char(2),
State char(50),
CoNoteText TEXT,
CoLocationID char(10),
Warehouse char(10),
LocationName char(255),
TaxRegID char(50),
TaxZoneID char(10),
ShipComplete bit,
LocationID char(10),
SameasMainInfo bit,
BranchAddrLine1 char(50),
BranchAddrLine2 char(50),
BranchCity char(50),
BranchCountry char(2),
BranchState char(50),
BranchPostalCode char(20),
BranchBusinessName char(255),
BranchAttention char(255),
BranchEmail char(255),
BranchWeb char(255),
BranchPhone1 char(50),
BranchPhone2 char(50),
BranchFax char(50),
SameasMainAddr bit,
LocBusinessName char(255),
LocAttention char(255),
LocEmail char(255),
LocWeb char(255),
LocPhone1 char(50),
LocPhone2 char(50),
LocFax char(50),
LocAddrLine1 char(50),
LocAddrLine2 char(50),
LocCity char(50),
LocCountry char(2),
LocState char(50),
LocPostalCode char(20),
DefaultCountry char(2),
AccessRole char(64),
LocTaxRegID char(50),
SalesSub char(30),
ExpenseSub char(30),
FreightSub char(30),
DiscountSub char(30),
CuryGainLossSub char(30),
Description char(60),
CurySymbol char(10),
DecimalPrecision smallint,
BaseCurrencyID char(5),
PhoneMask char(50))
GO" Where RefNum = 3

Table Schema:

RefNum          Int
Description     nvarchar
Query           ntext (I tried nvarchar max also)

I found conflicting articles stating this could/ could not be because of the length of my SQL statement

Questions:

1. Is this true?
2. If so how do I get around it?

Answer:

It ended up being because there where tabs and line breaks within my SQL statements

Sounds like you've got a length limit on a text field in your database. You'll need to break your text up into 128-character long strings, or modify your table's schema to allow longer strings.

Can you show us your table schema and an example of the data you're trying to insert?

SqlCe is a unicode-only database. So if your are using VARCHAR fields, mainly inside CREATE TABLE operations, you must change to the NVARCHAR datatype. Otherwise you can get that error.

Edit: This is true for CHAR fields as well...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM