易截截图软件、单文件、免安装、纯绿色、仅160KB

sql简单函数用法

定义函数
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER function [dbo].[FunJSLC](@carid bigint,@date datetime)
returns decimal
as
begin
declare @jslc decimal
set @jslc=(select JSLC from BYReMIn where iCarID=@carid and dtDate=@date)
return(@jslc)
end
存储过程应用函数
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER proc [dbo].[BYProc]
as
declare @jglc decimal
select cCode,dtDate ,cLBName,dMoney ,JSLC=dbo.FunJSLC(iCarID,dtDate),
JGLC=(dbo.FunJSLC(iCarID,dtDate)-dbo.Funccclc(iCarID)),
CCLC=dbo.Funccclc(iCarID),cHandler,cUName,cBYXM,cMemo into #t  from vBYB
select cCode as '车牌号',dtDate as '保养日期',cLBName as '保养类别',dMoney as '保养费用',
JSLC as '上次保养里程',CCLC as '当前里程',cHandler as '经手人',cUName as '保养单位',
cBYXM as '保养项目',cMemo as '备注'
 from #t where CCLC>JSLC
dbo.FunJSLC(iCarID,dtDate)即函数FunJSLC的返回值
了解最基本的定义调用会用就OK
这样实现统计的时候就方便多了,用sql去处理,使程序代码简洁,有效率!


相关文档:

sql server if嵌套基本语法

例子:
if 1<>1
begin
   if  5<0
      begin
            print('失败')
       end
       else begin
     &nbs ......

Config SQL Server for JDBC Access

1. In "MicroSoft SQL Server Management Studio", right click SQL Server instance, select "Properties", select "Security" in left panel and check "SQL Server and Windows Authentication mode" in right Panel.
2. In "SQL  Server Configuration Manager", select "SQL Server Network Configuration > ......

DBMS_SQL包实现动态SQL

.在查询中会遇到 UNION ALL,它的用法和union一样,只不过union含有distinct的功能,它会把两张表了重复的记录去掉,而union all不会,所以从效率上,union all 会高一点.
2.union all 是按原先顺序排列的,union 把两张表中的重复数据去掉后还进行了重新排序
声明:此文来源于网路!
内容摘要:在PL/SQL开发过程中,使用SQL, ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号