Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 377
  • Last Modified:

SQL 2000

I have a nvarchar field set to a length of 4,000.  So, of course, I cannot insert over 900 characters into it.

Any ideas?
0
classnet
Asked:
classnet
  • 4
  • 3
  • 2
2 Solutions
 
Patrick MatthewsCommented:
classnet,

Surely you can insert 900 characters into a nvarchar(4000) column.

Do you need to restate the problem?

:)

Patrick
0
 
classnetAuthor Commented:
Check it out Patrick... just spent forever adding and deleteing characters to find out why an obiously under 4,000 piece of text doesn't fit.  

The limit with varchar is 8,000 yet only really works up to 900 as well.
0
 
Patrick MatthewsCommented:
Something else is your problem, then, because both of the following SELECTs are returning 1500 as expected:

DECLARE @foo nvarchar(4000)
SET @foo = REPLICATE('x', 1500)
SELECT LEN(@foo)
CREATE TABLE zzz (foo nvarchar(4000))
INSERT INTO zzz (foo) VALUES (@foo)
SELECT LEN(foo) FROM zzz
DROP TABLE zzz

Open in new window

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
Aneesh RetnakaranDatabase AdministratorCommented:
seems like you are cheking the length thru the results from the query.
you need to set the maximum column output length in query analyser.
from query analyser -> ortions -> lresults -> max lenth
set that field to 8092 (which is max)


if you jsy want to get the length from the query , use
select len(columnName) from tableName
0
 
classnetAuthor Commented:
Actually what I am trying to do is to put a 975 character question into this field... adding a letter at a time, and rerunning the page, I see that it fails at character 901.
0
 
Aneesh RetnakaranDatabase AdministratorCommented:
how are you inserting ?

did you run the query tht return the length
0
 
classnetAuthor Commented:
select len(columnName) from tableName  will return the length of the data in that field.

sqlStatement = "insert into Questions Values('" & Request.Form("category") & "', " & Request.Form("questionnum") & ", '" & Request.Form("question") & "')"

Response.Write sqlStatement

objConnection.Execute SQLStatement,,129

This "insert" works find until Request.Form("question") > 900
0
 
classnetAuthor Commented:
Ok guys... how do I handle... the data is actually in there and all is well.  I just, on some questions, can't see the data from the Enterprise manager.

Who gets points?
0
 
Patrick MatthewsCommented:
I'd be amenable to a split :)
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

  • 4
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now