SQL insert update varchar问题

perpyy 2010-03-02 07:45:05
create table test
(
test_id varchar(50)
)

insert into test(test_id) values('0222566')


select * from test 时显示的数据是 222566

那个0去那了呢,要想得到的是0222566,该怎么办

...全文
81 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
perpyy 2010-03-02
  • 打赏
  • 举报
回复
哦,OK了,原来我update user_info set user_class=0600 where user_id='123'
改成这样对了 update user_info set user_class='0600' where user_id='123'
少了这个''
流氓兔 2010-03-02
  • 打赏
  • 举报
回复
引用 2 楼 bancxc 的回复:
不可能吧...?????
SQL codecreatetable test
(
test_idvarchar(50)
)insertinto test(test_id)values('0222566')--
--(1 行受影响)
--test_id
----------------------------------------------------
--0222566
--
--(1 行受影响)
--select*from testdroptable test

顶!
bancxc 2010-03-02
  • 打赏
  • 举报
回复
--可能是int
create table test
(
test_id int
)

insert into test(test_id) values('0222566')

--(1 行受影响)
--test_id
-------------
--222566
--
--(1 行受影响)
--

select * from test

drop table test
sql_db 2010-03-02
  • 打赏
  • 举报
回复
你确认test_id是varchar(50)吗? 可能是插入的时候把它转成int了
bancxc 2010-03-02
  • 打赏
  • 举报
回复
不可能吧...?????

create table test
(
test_id varchar(50)
)

insert into test(test_id) values('0222566')

--
--(1 行受影响)
--test_id
----------------------------------------------------
--0222566
--
--(1 行受影响)
--

select * from test

drop table test

22,209

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧