Friday, February 10, 2012

Cant get proper Field size using Enterprise Manager

This is frustrating. Im new at MS SQL and have created a table using Enterprise Manager. I need one of the fields to hold a paragraph or page of text... Ive tried every data type and even those with max length of 8000 or greater, I cannot get it to save more than the first 256 characters. I use an "INSERT" or "UPDATE" command from a PHP script on the front end...

any help would be amazing!

thank you!

michael wolffhave you thought that perhaps it is php that is not letting your text be longer then 256??

if you are using sql to insert the record get php to print out the sql that it is sending to the server and then see what happens if you execute that in the query analyzer|||Originally posted by rokslide
have you thought that perhaps it is php that is not letting your text be longer then 256??

if you are using sql to insert the record get php to print out the sql that it is sending to the server and then see what happens if you execute that in the query analyzer

the php shows the field as it should be... then i execute the INSERT... then missing text!|||have you actually tried executing the sql in the query analyzer?

I have been doing web based updates to sql for ages and I have only experienced this problem when I had stuffed up the command somewhere.|||you mean running the insert directly in EM to see if it takes the field size?

no, but ill try it now!|||i tried it and got this:

*********
Server: Msg 103, Level 15, State 7, Line 1
The identifier that starts with 'IN CASE YOU WERE WONDERING!! We've had some problems with our host and are currently working on fixing the problems this has cau' is too long. Maximum length is 128.
Server: Msg 128, Level 15, State 1, Line 1
The name 'IN CASE YOU WERE WONDERING!! We've had some problems with our host and are currently working on fixing the problems this has cau' is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted.
************

its a 'VARCHAR' field of max length 8000... whys it telling me the max is 128 here? and whats it mean by "The nam"? its just text...

*****

heres the statement i ran:

INSERT INTO headlines VALUES (getdate(),"IN CASE YOU WERE WONDERING!! We've had some problems with our host and are currently working on fixing the problems this has caused with the site. Just getting tour dates updated, BIG TEXTBIG TEXTBIG TEXTBIG TEXTBIG TEXTBIG TEXTBIG TEXTBIG TEXTBIG TEXTBIG TEXTBIG TEXT 25 BIG TEXTBIG TEXTBIG TEXTBIG TEXTBIG TEXTBIG TEXT 50 BIG TEXTBIG TEXTBIG TEXTBIG TEXTBIG TEXTBIG TEXT 100",25)

field types are: datetime, varchar, numeric...

and ideas?

thank you.

michael wolff|||okie, well that error message is not coming from MS SQL. MS SQL would say something like - Action aborted. String or Binary data would have been truncated - or some such...

can't remember the exact syntax...

so something else is saying that the field is 128/256.

in your php do you define the fields that you are putting data into? do they have default values for things like length??

I have passed the error to a friend that uses php and will pass on what he says.|||dont need to define the fields... well, its just a 'textarea' html field... and that value is passed into the 'INSERT' command...

the errors i posted above i got directly from the Query Analyzer... so i dont know...

please let me know what your friend says!

thank you

michael wolff|||Hi Michael,

I wonder if it's not just a problem with your double quotes around the string.
Could you try it with 'single quotes' (apostrophes?).
SQL thinks you refer to a column or other database name if you put it within double quotes.

Cheers,
Robert|||still cut it off at 254 characters..... and this is directly with the QA... so its the same results as doing it from a PHP script...|||Can you provide me with the script to create the table and the insert statement you're using and I'll take a look for you ?

Thanks
Mark|||i created the table directly in EM...

but heres the INSERT code, pretty straighforward:

$query="INSERT INTO headlines VALUES (getdate(),\"$newheadline\",\"$theid\")";|||Originally posted by celloshred
i created the table directly in EM...

You could right click the table in EM and choose All tasks->Generate SQL Scripts to get the script that would help us track down the problem.

I guess this is not the case, but there was a limit in old ODBC drivers which cut off chars/varchars at 256 characters.|||you got there just before me :-)|||not sure what that is, but heres the file (attached)|||Its the double quotes around the inserted string. Use single quotes.
However as you have a single quote inside the string you provided, additional quotes will need to surround those quotes.

Or you could on use run via iSQL

SET quoted_identifier OFF

which will allow you to use the query just as you have it, ie with double quotes

No comments:

Post a Comment