当前位置: 代码迷 >> Sql Server >> 怎样把Sql语句转化成存储过程语句,该怎么处理
  详细解决方案

怎样把Sql语句转化成存储过程语句,该怎么处理

热度:43   发布时间:2016-04-27 17:03:21.0
怎样把Sql语句转化成存储过程语句,急
Sql   =   "Select   A,B   From   Table1 "
Set   Rs   =   Conn.ExeCute(Sql)
If   not   Rs.Eof   Then
      s   =   " "
      Do   While   Not   Rs.Eof
            s   =   s   &   Rs(0)   & "+ "&   Rs(1)
      Rs.MoveNext
      Loop
End   If

------解决方案--------------------
create procedure sp_test(@str varchar(8000) output)
as
begin
set @str= ' '
Select @[email protected]+ ' '+isnull(A, ' ')+ '+ '+isnull(B, ' ') From Table1
return
end
go

declare @str varchar(8000)
exec sp_test @str output
print @str
------解决方案--------------------

create function get_result()
returns varchar(4000)
as
begin
declare @sql varchar(4000)
select @sql= ' '
select @[email protected]+A+B from Table1
return @sql
end
go


Sql = "Select dbo.get_result() "
Set Rs = Conn.ExeCute(Sql)
If not Rs.Eof Then
s = Rs(0)
End If
  相关解决方案