create function [dbo].[GetSumpageByIp](@customerID bigint ,@ip varchar(200),@stime datetime,@endTime datetime)
returns float
as
begin
declare @temp1 varchar(8000)
declare @temp float
set @temp1='
select @temp= Convert(numeric(10, 2),Count(CountURl)) from Count_RandD'+Convert(varchar(50),@CustomerID)+'
where CustomerID='''+convert(varchar(50),@CustomerID)+''' and
countTime between '''+convert(varchar(100),@stime)+''' and '''+convert(varchar(100),@endtime)+''' and
countIp='''+@ip+''''
exec (@temp1)
return @temp
end--------
这个怎么改成存储过程,并说一下存储过程怎么用,谢谢!
returns float
as
begin
declare @temp1 varchar(8000)
declare @temp float
set @temp1='
select @temp= Convert(numeric(10, 2),Count(CountURl)) from Count_RandD'+Convert(varchar(50),@CustomerID)+'
where CustomerID='''+convert(varchar(50),@CustomerID)+''' and
countTime between '''+convert(varchar(100),@stime)+''' and '''+convert(varchar(100),@endtime)+''' and
countIp='''+@ip+''''
exec (@temp1)
return @temp
end--------
这个怎么改成存储过程,并说一下存储过程怎么用,谢谢!
解决方案 »
- 在数据库中要用decimal不能用float 那在程序中呢?
- 在线等。。。如果一列全是NULL,SELECT MAX是什么结果
- 这样的sql语句怎么写呢
- 借咱这里的人气,delphi里都没人回答!
- SQL触发器问题
- 求助:SQL2005备份总是出错
- 关于sql2000远程访问的问题!!愁死我了!
- 50分请大家看看http://www.csdn.net/Expert/TopicView1.asp?id=910123,给点意见!
- 菜鸟提问查询语句问题!!!在线等待
- 一个查询问题,请大家帮个忙!
- SQLServer2005服务端端口号改为非1433后(如:1148)客户端无法链接
- CSDN公告:4月底将强制结帖
@customerID bigint ,
@ip varchar(200),
@stime datetime,
@endTime datetime
returns float
as
declare @temp1 varchar(8000)
declare @temp float
set @temp1='
select @temp= Convert(numeric(10, 2),Count(CountURl)) from Count_RandD'+Convert(varchar(50),@CustomerID)+'
where CustomerID='''+convert(varchar(50),@CustomerID)+''' and
countTime between '''+convert(varchar(100),@stime)+''' and '''+convert(varchar(100),@endtime)+''' and
countIp='''+@ip+''''
exec (@temp1)
@customerID bigint ,
@ip varchar(200),
@stime datetime,
@endTime datetime
as
declare @temp1 varchar(8000)
declare @temp float
set @temp1='
select @temp= Convert(numeric(10, 2),Count(CountURl)) from Count_RandD'+Convert(varchar(50),@CustomerID)+'
where CustomerID='''+convert(varchar(50),@CustomerID)+''' and
countTime between '''+convert(varchar(100),@stime)+''' and '''+convert(varchar(100),@endtime)+''' and
countIp='''+@ip+''''
exec (@temp1)
go
--调用
EXEc protest 1,'1xs','2007-04-26','2007-04-26'
@customerID bigint ,
@ip varchar(200),
@stime datetime ,
@endTime datetime ,
@return float output)
as
begin
declare @sql nvarchar(8000)
set @sql=N'
select @return=Convert(numeric(10, 2),Count(CountURl)) from Count_RandD'+Convert(varchar(50),@CustomerID)+'
where CustomerID='''+convert(varchar(50),@CustomerID)+''' and
countTime between '''+convert(varchar(100),@stime)+''' and '''+convert(varchar(100),@endtime)+''' and
countIp='''+@ip+''''
exec @sql,N'@return float output',@return output
return
end
godeclare @customerID bigint,@ip varchar(200),@stime datetime,@endTime datetime,@return float
set ...exec [dbo].[GetSumpageByIp] @customerID,@ip,@stime,@endTime,@return outputselect @return
go
as
begin
declare @temp1 nvarchar(4000)
set @temp1='
select @temp= Convert(numeric(10, 2),Count(CountURl)) from Count_RandD'+Convert(varchar(50),@CustomerID)+'
where CustomerID='''+convert(varchar(50),@CustomerID)+''' and
countTime between '''+convert(varchar(100),@stime)+''' and '''+convert(varchar(100),@endtime)+''' and
countIp='''+@ip+''''
--print @temp1
exec sp_executesql @temp1,N'@temp float output',@temp output
end
Go
declare @temp float
exec GetSumpageByIp 1,'2','2007-04-23','2007-04-23',@temp output
print @temp
要在select 中 执行存储过程怎么执行!
-------------------------------------------------
不行.不能像函数那样调用.
另外,可能要用游标逐行处理才行.