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

SQL一个存储过程调用另一个存储过程 获得返回值问题

第一种方法: 使用output参数
USE AdventureWorks;
GO
IF OBJECT_ID ( 'Production.usp_GetList', 'P' ) IS NOT NULL
    DROP PROCEDURE Production.usp_GetList;
GO
CREATE PROCEDURE Production.usp_GetList @product varchar(40)
    , @maxprice money
    , @compareprice money OUTPUT
    , @listprice money OUT
AS
    SELECT p.name AS Product, p.ListPrice AS 'List Price'
    from Production.Product p
    JOIN Production.ProductSubcategory s
      ON p.ProductSubcategoryID = s.ProductSubcategoryID
    WHERE s.name LIKE @product AND p.ListPrice < @maxprice;
-- Populate the output variable @listprice.
SET @listprice = (SELECT MAX(p.ListPrice)
        from Production.Product p
        JOIN  Production.ProductSubcategory s
          ON p.ProductSubcategoryID = s.ProductSubcategoryID
        WHERE s.name LIKE @product AND p.ListPrice < @maxprice);
-- Populate the output variable @compareprice.
SET @compareprice = @maxprice;
GO
另一个存储过程调用的时候:
Create Proc Test
as
DECLARE @compareprice money, @cost money
EXECUTE Production.usp_GetList '%Bikes%', 700,
    @compareprice OUT,
    @cost OUTPUT
IF @cost <= @compareprice
BEGIN
    PRINT 'These products can be purchased for less than
    $'+RTRIM(CAST(@compareprice AS varchar(20)))+'.'
END
ELSE
    PRINT 'The prices for all products in this category exceed
    $'+ RTRIM(CAST(@compareprice AS varchar(20)))+'.'
第二种方法:创建一个临时表
create proc GetUserName
as
begin
    select 'UserName'
end
Create table #tempTable (userName nvarchar(50))
insert into #tempTable(userName)


相关文档:

ORACLE 10G PL/SQL PACKAGE学习笔记


DBMS_CHANGE_NOTIFICATION
对象(表)数据更新通知
DBMS_APPLICATION_INFO
设置/读取SESSION APPLICATION信息,操作V$SESSION_LONGOPS
DBMS_ALERT
告警
DBMS_DATAPUMP
数据迁移
DBMS_DB_VERSION
数据库版本定义
DBMS_DDL
Compiles、wrapped、Reorganizes 对象
DBMS_DEBUG
ORACLE DEPL/SQL debugger 工具
DB ......

sql server日期时间函数

Sql Server中的日期与时间函数 
1.  当前系统日期、时间 
    select getdate()  
2. dateadd  在向指定日期加上一段时间的基础上,返回新的 datetime 值
   例如:向日期加上2天 
   sele ......

SQL UNIQUEIDENTIFIER

当你正在处理被多个站点(像在跨国公司条件下)使用的大数据库时,你也许会遇到保证表格对象唯一性这样的棘手问题。在这种情形下,可能只能靠UNIQUEIDENTIFIER来解决。UNIQUEIDENTIFIER是一个保存全局唯一标识符的GUID数据类型。GUID是一个保证唯一的二进制数,因此几乎没有别的计算机会产生同一个值。
GUID的唯一值是由计 ......

SQL Server 2005 Analysis Services部署时报告错误

 数据源......包含无法用于处理操作的 ImpersonationMode。
解决方法:
服务器连接改为“使用服务账户”。
具体操作:
在数据源里的项目上点击右键->打开->数据源设计器 , 选择“模拟信息”标签->选择“使用服务账户”,确定,执行部署。 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号