all groups > sql server new users > december 2006 >
You're in the

sql server new users

group:

a question about insert into char field


Re: a question about insert into char field Arnie Rowland
12/1/2006 8:39:22 AM
sql server new users: No, that will fail with a error message that the data would be truncated.

You could truncate by using CAST() or CONVERT() in the INSERT statement.

Insert Into ... Values ( cast( "HelloYou" AS char(5) ),

--
Arnie Rowland, Ph.D.
Westwood Consulting, Inc

Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous

You can't help someone get up a hill without getting a little closer to the
top yourself.
- H. Norman Schwarzkopf


[quoted text, click to view]

a question about insert into char field John61
12/1/2006 10:17:15 AM
If a table has a char field with a length 5, is it possible to allow us to
insert a longer string, but the field just takes the first 5 chars?

For example, we use Insert Into ... Values ("HelloYou"), "Hello" can be
inserted without an error. Is there an option in SQL server on this?

Thanks,

John

Re: a question about insert into char field Joe McArthur
12/1/2006 2:07:50 PM
In addition to what Arnie said you could also use: left("HelloYou", 5)


"John61" <wanghaodong@yahoo.com> wrote in
news:#DillQWFHHA.1912@TK2MSFTNGP03.phx.gbl:

[quoted text, click to view]
AddThis Social Bookmark Button