读书人

插入数据遇到个小疑点

发布时间: 2012-01-23 21:57:28 作者: rapoo

插入数据遇到个小问题
我知道如果从表table中读取数据然后插入table2中用:
insert table2 (aaa,bbb,ccc)
select aaa,bbb,ccc from table where aaa= 'xxx '
如果字段bbb前面要加字符,应该怎么弄?比如table2中bbb的数据是table中的数据在前面加前缀字母“gd”

[解决办法]
insert table2 (aaa,bbb,ccc)
select aaa, 'gd '+bbb,ccc from table where aaa= 'xxx '

[解决办法]
insert table2 (aaa,bbb,ccc)
select aaa, 'gd '+bbb,ccc from table where aaa= 'xxx '

[解决办法]
insert table2 (aaa,bbb,ccc)
select aaa,stuff(bbb,1,2, 'gd '),ccc from table where aaa= 'xxx '

读书人网 >SQL Server

热点推荐