怎样把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 @str=@str+ ' '+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 @sql=@sql+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