CREATEPROCEDUREsp_productPage
@intStartTINYINT=1,
@intEndTINYINT=10
withENCRYPTION
AS
Declare@strProductIDVARCHAR(8),@strProductNameVARCHAR(20),
@strSQL1VARCHAR(100),
@strSQL2VARCHAR(100),
@strSQL3VARCHAR(100),
@strSQL4VARCHAR(100),
@strSQL5VARCHAR(100),
@strSQL6VARCHAR(100),
@strSQL7VARCHAR(100),
@strSQL8VARCHAR(100),
@strSQL9VARCHAR(100),
@strSQL10VARCHAR(100),
@intCCountTINYINT,
@intCountTINYINT,
@iTINYINT
select@i=1
Declarecur_ProductSCROLLCURSORFor
SelectProductID,ProductNamefromKF_ProductorderbyProductID
Select@intCCount=count(productId)FromKF_Product
opencur_Product
FetchABSOLUTE@intStartFromcur_ProductInto@strProductID,@strProductName
if@@FETCH_STATUS=0
Select@intCount=@intStart
Fetchcur_ProductInto@strProductID,@strProductName
if@@FETCH_STATUS=0
Begin
Select@intCount=@intCount+1
Select@strSQL1=SelectproductId=+@strProductID+,productName=+@strProductName+,ProductCount=+convert(VARCHAR,@intCount)+,ProductSumCount=+convert(VARCHAR,@intCCount)+Union
End
else
Begin
Select@strSQL1=SelectproductId=+@strProductID+,productName=+@strProductName+,ProductCount=+convert(VARCHAR,@intcCount)+,ProductSumCount=+convert(VARCHAR,@intCCount)
GotoEndPro
End
Fetchcur_ProductInto@strProductID,@strProductName
if@@FETCH_STATUS=0
Begin
Select@intCount=@intCount+1
Select@strSQL2=SelectproductId=+@strProductID+,productName=+@strProductName+,ProductCount=+convert(VARCHAR,@intCount)+,ProductSumCount=+convert(VARCHAR,@intCCount)+Union
End
else
Begin
Select@strSQL2=SelectproductId=+@strProductID+,productName=+@strProductName+,ProductCount=+convert(VARCHAR,@intcCount)+,ProductSumCount=+convert(VARCHAR,@intCCount)
GotoEndPro
End
Fetchcur_ProductInto@strProductID,@strProductName
if@@FETCH_STATUS=0
Begin
Select@intCount=@intCount+1
Select@strSQL3=SelectproductId=+@strProductID+,productName=+@strProductName+,ProductCount=+convert(VARCHAR,@intCount)+,ProductSumCount=+convert(VARCHAR,@intCCount)+Union
End
else
Begin
Select@strSQL3=SelectproductId=+@strProductID+,productName=+@strProductName+,ProductCount=+convert(VARCHAR,@intcCount)+,ProductSumCount=+convert(VARCHAR,@intCCount)
GotoEndPro
End
Fetchcur_ProductInto@strProductID,@strProductName
if@@FETCH_STATUS=0
Begin
Select@intCount=@intCount+1
Select@strSQL4=SelectproductId=+@strProductID+,productName=+@strProductName+,ProductCount=+convert(VARCHAR,@intCount)+,ProductSumCount=+convert(VARCHAR,@intCCount)+Union
End
else
Begin
Select@strSQL4=SelectproductId=+@strProductID+,productName=+@strProductName+,ProductCount=+convert(VARCHAR,@intcCount)+,ProductSumCount=+convert(VARCHAR,@intCCount)
GotoEndPro
End
Fetchcur_ProductInto@strProductID,@strProductName
if@@FETCH_STATUS=0
Begin
Select@intCount=@intCount+1
Select@strSQL5=SelectproductId=+@strProductID+,productName=+@strProductName+,ProductCount=+convert(VARCHAR,@intCount)+,ProductSumCount=+convert(VARCHAR,@intCCount)+Union
End
else
Begin
Select@strSQL5=SelectproductId=+@strProductID+,productName=+@strProductName+,ProductCount=+convert(VARCHAR,@intcCount)+,ProductSumCount=+convert(VARCHAR,@intCCount)
GotoEndPro
End
Fetchcur_ProductInto@strProductID,@strProductName
if@@FETCH_STATUS=0
Begin
Select@intCount=@intCount+1
Select@strSQL6=SelectproductId=+@strProductID+,productName=+@strProductName+,ProductCount=+convert(VARCHAR,@intCount)+,ProductSumCount=+convert(VARCHAR,@intCCount)+Union
End
else
Begin
Select@strSQL6=SelectproductId=+@strProductID+,productName=+@strProductName+,ProductCount=+convert(VARCHAR,@intcCount)+,ProductSumCount=+convert(VARCHAR,@intCCount)
GotoEndPro
End
Fetchcur_ProductInto@strProductID,@strProductName
if@@FETCH_STATUS=0
Begin
Select@intCount=@intCount+1
Select@strSQL7=SelectproductId=+@strProductID+,productName=+@strProductName+,ProductCount=+convert(VARCHAR,@intCount)+,ProductSumCount=+convert(VARCHAR,@intCCount)+Union
End
else
Begin
Select@strSQL7=SelectproductId=+@strProductID+,productName=+@strProductName+,ProductCount=+convert(VARCHAR,@intcCount)+,ProductSumCount=+convert(VARCHAR,@intCCount)
GotoEndPro
End
Fetchcur_ProductInto@strProductID,@strProductName
if@@FETCH_STATUS=0
Begin
Select@intCount=@intCount+1
Select@strSQL8=SelectproductId=+@strProductID+,productName=+@strProductName+,ProductCount=+convert(VARCHAR,@intCount)+,ProductSumCount=+convert(VARCHAR,@intCCount)+Union
End
else
Begin
Select@strSQL8=SelectproductId=+@strProductID+,productName=+@strProductName+,ProductCount=+convert(VARCHAR,@intcCount)+,ProductSumCount=+convert(VARCHAR,@intCCount)
GotoEndPro
End
Fetchcur_ProductInto@strProductID,@strProductName
if@@FETCH_STATUS=0
Begin
Select@intCount=@intCount+1
Select@strSQL9=SelectproductId=+@strProductID+,productName=+@strProductName+,ProductCount=+convert(VARCHAR,@intCount)+,ProductSumCount=+convert(VARCHAR,@intCCount)+Union
End
else
Begin
Select@strSQL9=SelectproductId=+@strProductID+,productName=+@strProductName+,ProductCount=+convert(VARCHAR,@intcCount)+,ProductSumCount=+convert(VARCHAR,@intCCount)
GotoEndPro
End
Fetchcur_ProductInto@strProductID,@strProductName
if@@FETCH_STATUS=0
Begin
Select@intCount=@intCount+1
Select@strSQL10=SelectproductId=+@strProductID+,productName=+@strProductName+,ProductCount=+convert(VARCHAR,@intCount)+,ProductSumCount=+convert(VARCHAR,@intCCount)
End
else
Begin
Select@strSQL10=SelectproductId=+@strProductID+,productName=+@strProductName+,ProductCount=+convert(VARCHAR,@intcCount)+,ProductSumCount=+convert(VARCHAR,@intCCount)
GotoEndPro
End
EndPro:
closecur_Product
DEALLOCATEcur_Product
print@strSQL1
print@strSQL2
print@strSQL3
exec(@strSQL1+@strSQL2+@strSQL3+@strSQL4+@strSQL5+@strSQL6+@strSQL7+@strSQL8+@strSQL9+@strSQL10)
GO
存储历程创立乐成后,就能够在ASP中做以下挪用
strSQL="sp_productPage1,10
rst.openstrSQL,conn,3,1
就能够了