Sunday, February 19, 2012

"insert into" with text type - newbie

Hello,

When I try "Insert Into" with a text column value that's very long, I
only get a cropped version inserted (I know because when I
programmatically access the field, it's cropped-- I'm not just
assuming this from query manager). The text column has a default size
of small, however I don't understand why it is only inserting the
default amoutn instead of the whole string. I am using "Insert Into
table (blah, blah) values (blah, 'loooooooooooooooooooooooooooong
entry')", and programmatically running that command.

I'm stumped. Why is it inserting only part of the long entry value?"vavavoomy2" <vavavoomy2@.yahoo.com> wrote in message
news:c5e42899.0310280942.177d251c@.posting.google.c om...
> Hello,
> When I try "Insert Into" with a text column value that's very long, I
> only get a cropped version inserted (I know because when I
> programmatically access the field, it's cropped-- I'm not just
> assuming this from query manager). The text column has a default size
> of small, however I don't understand why it is only inserting the
> default amoutn instead of the whole string. I am using "Insert Into
> table (blah, blah) values (blah, 'loooooooooooooooooooooooooooong
> entry')", and programmatically running that command.
> I'm stumped. Why is it inserting only part of the long entry value?

What does a "default size of small" mean? Text columns in MSSQL don't have a
variable width, are you talking about a char/varchar column?

In any case, you should probably check if you have ANSI_WARNINGS set OFF in
the connection properties for your client. By default this is on (for OLE
DB/ODBC at least), and inserting data which would be truncated gives an
error. Setting it to off suppresses the error and allows the insert to
happen.

If that isn't the case, can you post your CREATE TABLE statement, and an
INSERT statement which reproduces the problem? Also, does the error happen
when you execute the INSERT manually in Query Analyzer or only
programmatically?

Simon|||"vavavoomy2" <vavavoomy2@.yahoo.com> wrote in message
news:c5e42899.0310280942.177d251c@.posting.google.c om...
> Hello,
> When I try "Insert Into" with a text column value that's very long, I
> only get a cropped version inserted (I know because when I
> programmatically access the field, it's cropped-- I'm not just
> assuming this from query manager). The text column has a default size
> of small, however I don't understand why it is only inserting the
> default amoutn instead of the whole string. I am using "Insert Into
> table (blah, blah) values (blah, 'loooooooooooooooooooooooooooong
> entry')", and programmatically running that command.
> I'm stumped. Why is it inserting only part of the long entry value?

What does a "default size of small" mean? Text columns in MSSQL don't have a
variable width, are you talking about a char/varchar column?

In any case, you should probably check if you have ANSI_WARNINGS set OFF in
the connection properties for your client. By default this is on (for OLE
DB/ODBC at least), and inserting data which would be truncated gives an
error. Setting it to off suppresses the error and allows the insert to
happen.

If that isn't the case, can you post your CREATE TABLE statement, and an
INSERT statement which reproduces the problem? Also, does the error happen
when you execute the INSERT manually in Query Analyzer or only
programmatically?

Simon

No comments:

Post a Comment