SQL中如何用一个表更新另一个表
for ACCESS :
update a, b set a.name=b.name1 where a.id=b.id
for SQL Server:
"update a set a.name=b.name1 from a,b where a.id=b.id"
update a set a.status=b.status
from table1 a,table2 b
where a.id1=b.id1
update a inner join b on a.a1=b.b1 set a.a2=b.b2条件
update table1 set a.status = b.status
from table1 a inner join table2 b
on a.idl = b.idl
http://topic.csdn.net/t/20041013/14/3451961.html
http://www.cnblogs.com/hanguoji/archive/2007/02/01/636723.aspx
相关文档:
select name from syscolumns where id in (select id from sysobjects where type = 'u' and name = '相应表名')
用以上sql语句输入相应表名就可以查到表的字段名,对应好数据库 查询是否存在该表语句
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tb_cost]') and OBJECTPROPER ......
*
sql xml 入门:
--by jinjazz
--http://blog.csdn.net/jinjazz
1、xml: 能认识元素、属性和值
2、xpath: 寻址语言,类似wind ......
SQL Server:
Select TOP N * from TABLE Order By NewID()
Select TOP N * from TABLE Order By NewID()
NewID()函数将创建一个 uniqueidentifier 类型的唯一值。上面的语句实现效果是从Table中随机读取N条记录。
Access:
Select TOP N *&n ......
----start
动态SQL是在程序运行时构造的,要执行单条SQL,使用EXECUTE IMMEDATE 语句;当批量执行SQL时,先使用PREPARE 语句构造SQL,然后使用EXECUTE 语句执行。
一:Prepare语句:用来构造批量SQL
语法:
PREPARE <sql-statement> [OUTPUT] INTO <result> [INPUT INTO] <input> ......