alter procedure pro_modify_shoukuan
@client_id int,@id int output
as
select @id=max(id) from [contract]
where client_id=@client_id
declare @id int
pro_modify_shoukuan 0045,@id请问下我这句最后的执行为什么老是说我有错误
错误如下
消息102,级别15,状态1,第3 行
'pro_modify_shoukuan' 附近有语法错误。
@client_id int,@id int output
as
select @id=max(id) from [contract]
where client_id=@client_id
declare @id int
pro_modify_shoukuan 0045,@id请问下我这句最后的执行为什么老是说我有错误
错误如下
消息102,级别15,状态1,第3 行
'pro_modify_shoukuan' 附近有语法错误。
解决方案 »
- 在SQL中去掉负号?
- 奇怪的问题。
- 如何将下表这样拆分?
- 求SQL语句,肯请各位看官挺力相助:)
- 使用链接服务器,执行带返回参数的oracle存储过程,如何获取参数返回值?
- sql server中如何设定字段默认值为空字符??
- 更简单的问题?
- 如何在数据库表中查找重复的值?
- 我要查询两个表,遇到一个难题
- 请问:ASP用SQL SERVER数据库数据库比用ACCESS快吧?但我的ASP+SQL比ASP+ACCESS慢了,why??
- 安装SQL 2008 Express sp1时出现registry properties are not valid under this context
- 优化sql语句
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
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)))+'.'
也declare过了
为什么还说我需要声明标量变量呢>?
declare @num int,
@sqls nvarchar(4000)
set @sqls='select count(*) from tableName'
exec(@sqls)
--如何将exec执行结果放入变量中? declare @num int,
@sqls nvarchar(4000)
set @sqls='select @a=count(*) from tableName '
exec sp_executesql @sqls,N'@a int output',@num output
select @num
参考上面的代码..加上OUT参数
@client_id int,@id int output
as
select @id=max(id) from [contract]
where client_id=@client_id
GOdeclare @id int
EXEC pro_modify_shoukuan 0045,@id
@client_id int,@id int output
as
select @id=max(id) from [contract]
where client_id=@client_id
GOdeclare @id int
EXEC pro_modify_shoukuan 0045,@id OUT
select @id