易截截图软件、单文件、免安装、纯绿色、仅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)


相关文档:

delphi中多条件SQL语句的增加注意事项

在DELPHI中常常要用到ADOQUERY中的SQL语句增加信息后执行,当要求增加条件(如参数时)中间的间隔很重要,搞不好就要出错:下举例说明我要表达的意思:
如:一个表:student 有 ksh,xm,xb,lqzy,lqcc几个字段,都为字符型。现要求按xb分组统计人数,同时lqcc要求限定条件。
一般情况下的SQL语句应该为: select xb,count(*) ......

SQL注入简单原理分析

 SQL注入简单分析
示例语句:
select * from admintable where adminName like '%a%'
在查询中我们一般在a这个地方由界面传入不同的值,当我们在a这里传入的值为“'”单引号时,拼凑成的SQL语句就如下:
select * from admintable where adminName like '%'%'
执行这句语句我们会发现出现以下异常: ......

java备份sql server数据库 存储过程

今天给大家分享一下如何备份和回复sql server 数据,
首先确保你具有DB的最高权限
在JAVA代码中 你可以这样写public class Opp extends TestCase{
public void test1()
{
try
{
Connection con = DBUtils.getConn();
String sql="backup database tdzl to disk='d:\\tdzl.bak'";
Statement st = con.c ......

[Oracle]高效的PL/SQL程序设计(四)

本系列文章导航
[Oracle]高效的PL/SQL程序设计(一)--伪列ROWNUM使用技巧
[Oracle]高效的PL/SQL程序设计(二)--标量子查询
[Oracle]高效的PL/SQL程序设计(三)--Package的优点
[Oracle]高效的PL/SQL程序设计(四)--批量处理
[Oracle]高效的PL/SQL程序设计(五)--调用存储过程返回结果集
[Oracle]高效的PL/SQL程序设计(六)- ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号