Sql server存储过程中 数据集的缓存
create procedure DeleteWareHouse_StoreArea_SummaryByPUR
(@po_no nvarchar(100))
as
begin
declare @cacheTable table(wh_id int);--声明一个table类型的变量
insert @cacheTable select wh_id from aps_inventory_store_area where description=@po_no--向变量@cacheTable中添加结果集
--select * from @cacheTable
delete aps_inventory_summary where wh_id in(select * from @cacheTable)
delete aps_inventory_store_area where wh_id in(select * from @cacheTable)
delete aps_inventory_warehouse where wh_id in(select * from @cacheTable)
end
相关文档:
在VS中写SQL语句的时候,千万万千要小心再小心,比如 说 数据类型的匹配, 单引号(这个能把人迷死)
where 子句中可千万不能有空格(当查询条件为字符串的时候能把你弄疯,我弄这个的时候都疯了几次了,什么都对就是查不出来,调试了N遍才发现。)不行了,吃饭去,再不吃看见活人都想咬了。 ......
我们要做到不但会写SQL,还要做到写出性能优良的SQL语句。
(1)选择最有效率的表名顺序(只在基于规则的优化器中有效):
Oracle的解析器按照从右到左的顺序处理from子句中的表名,from子句中写在最后的表(基础表 driving table)将被最先处理,在f ......
SQL SERVER 2005 中的日期时间类型
一. 数据类型
MS SQL Server 2005 有 datetime 和 smalldatetime 两种格式的日期时间数据类型。注意:没有单独的日期或时间类型。
datetime
数据库内部用两个 4 字节的整数存储 datetime 数据类型的值。第一个 4 字节存储基础日期(即 1900-1-1, base ......
---SQL实现完全排列组合
create function F_strSpit(@s varchar(200)) returns table
as
return(
select value=substring(@s,i,num)+substring(@s,num-1+j,1)
from (select num=number from spt_values where type='p' and number<len(@s) and number>0)TA,
(select i=number+1 from spt_values where type='p ......