菜鸟求一SQL语句,明天结贴
从oldtab中读取字段name,year,条件year字段在1999-2005之间的记录,将其写入newtab,,谢谢
------解决方案--------------------insert into newtb(name)
select name from oodtb where year> = '1999 ' and year <= '2005 '
------解决方案--------------------select name, year into newtab from oldtab where year > = 1999 and year <= 2005
------解决方案--------------------如果year是datetime类型:
insert into newtab
select name,[year] from oldtab where year([year]) between 1999 and 2005
------解决方案--------------------select [name], [year]
into newtab
from oldtab
where [year] between 1999 and 2005
------解决方案--------------------insert into newtab (name,year)
select name,[year] from oldtab where year > = 1999 and year <= 2005
------解决方案--------------------楼楼上
select name, year into newtab from oldtab where year > = 1999 and year <= 2005
正解
------解决方案--------------------楼上答案都是可以的
看楼主自己选择了
------解决方案--------------------insert into newtab
select name,year from oldtab where year(year) between 1999 and 2005
------解决方案-------------------- --假如没有newtab,重新建立一个新表:
select name,year into newtab from oldtab
where convert(varchar(4),year,120) between 1999 and 2005
--假如存在表结构newtab
insert into newtab(name,year) select name,year from oldtab
where convert(varchar(4),year,120) between 1999 and 2005