SQL Note

复制表(只复制结构,源表名:a 新表名:b) 
SQL: select * into b from a where 1<>1 

拷贝表(拷贝数据,源表名:a 目标表名:b) 
SQL: insert into b(a, b, c) select d,e,f from b; 

从其它数据的表中数据来修改当前表

update t_cardcontent260 set t_cardcontent260.field10=(select productname from Northwind.dbo.Products where t_cardcontent260.id=Northwind.dbo.Products.ProductID

or:
select top 1 * into 新表 from 旧表
truncate table 新表   --delete from 新表 

 


alter   table   '表名'   drop   column   age(删除列age)
CREATE TABLE tb(ID int, 名称 NVARCHAR(30), 备注 NVARCHAR(1000))
INSERT tb   SELECT 1,'DDD',1
UNION  ALL        SELECT 1,'5100','D'
UNION  ALL        SELECT 1,'5200','E'

select * from tb

set ROWCOUNT 2 select * from tb order by id

select right(名称,1) from tb where 备注='d'

posted @ 2006-11-30 11:29  '.Elvis.'  阅读(155)  评论(0)    收藏  举报