如何以表格格式从另一个存储过程获取存储过程的输出值

时间:2011-11-24 18:43:57

标签: sql-server sql-server-2005 sql-server-2008 tsql

我有一张包含itemIDImagepath(s)的以下数据的表

tableImagePath

ItemID     frontimage                          backimage
---------  ----------------------------------  ---------------------------------
772740509  2011\11\24\1\8014681_5_1_FRONT.tif  2011\11\24\1\8014681_5_1_BACK.tif
772740508  2011\11\24\1\8014680_4_1_FRONT.tif  2011\11\24\1\8014680_4_1_BACK.tif
772740507  2011\11\24\1\8014679_3_1_FRONT.tif  2011\11\24\1\8014679_3_1_BACK.tif
772740506  2011\11\24\1\8014678_2_1_FRONT.tif  2011\11\24\1\8014678_2_1_BACK.tif
772740505  2011\11\24\1\8014677_1_1_FRONT.tif  2011\11\24\1\8014677_1_1_BACK.tif
772740504  2011\11\24\1\8014676_5_1_FRONT.tif  2011\11\24\1\8014676_5_1_BACK.tif
772740503  2011\11\24\1\8014675_4_1_FRONT.tif  2011\11\24\1\8014675_4_1_BACK.tif
772740502  2011\11\24\1\8014674_3_1_FRONT.tif  2011\11\24\1\8014674_3_1_BACK.tif
772740501  2011\11\24\1\8014673_2_1_FRONT.tif  2011\11\24\1\8014673_2_1_BACK.tif
772740500  2011\11\24\1\8014672_1_1_FRONT.tif  2011\11\24\1\8014672_1_1_BACK.tif

我有一个存储过程,用于生成base64编码的图像输出(来自上面的imagepath)。

declare @base64image as varchar(max)
exec dbo.prIMGCLR_ReadImage_Base64 '2011\11\24\1\8014681_5_1_FRONT.tif', @base64image out 
select @base64image

返回输出,如下所示:

SUkqAAgAAAATAP4ABAABAAAAKwIAAAIBAwABAAAAAQA+gAAABwBAwABAAAAAQAAACIAAAAAQAAAMgAAAABAAAA....

注意:dbo.prIMGCLR_ReadImage_Base64存储过程实际上已被锁定,我无法打开源以查看其中的内容。 所以我只能使用这个过程,我没有其他函数返回base64编码的值。

现在,如果我使用相同的过程来获取FrontImageBackImage的base64编码值,输出应该如下所示......

tableImage_Base64Encoded

772740509   SUkqAAgAAAATAP4ABAABAAAAKwIAAAIBAwABAAAAAQA+gAAABwBAwABAAAAAQAAACIAAAAAQAAAMgAAAABAAAA...   SUkqAAgAAAATAP4ABAABAAAAKwIAAAIBAwABAAAAAQA+gAAABwBAwABAAAAAQAAACIAAAAAQAAAMgAAAABAAAA...
772740508   SUkqAAgAAAATAP4ABAABAAAAKwIAAAIBAwABAAAAAQA+gAAABwBAwABAAAAAQAAACIAAAAAQAAAMgAAAABAAAA...   SUkqAAgAAAATAP4ABAABAAAAKwIAAAIBAwABAAAAAQA+gAAABwBAwABAAAAAQAAACIAAAAAQAAAMgAAAABAAAA...
772740507   SUkqAAgAAAATAP4ABAABAAAAKwIAAAIBAwABAAAAAQA+gAAABwBAwABAAAAAQAAACIAAAAAQAAAMgAAAABAAAA...   SUkqAAgAAAATAP4ABAABAAAAKwIAAAIBAwABAAAAAQA+gAAABwBAwABAAAAAQAAACIAAAAAQAAAMgAAAABAAAA...
772740506   SUkqAAgAAAATAP4ABAABAAAAKwIAAAIBAwABAAAAAQA+gAAABwBAwABAAAAAQAAACIAAAAAQAAAMgAAAABAAAA...   SUkqAAgAAAATAP4ABAABAAAAKwIAAAIBAwABAAAAAQA+gAAABwBAwABAAAAAQAAACIAAAAAQAAAMgAAAABAAAA...
772740505   SUkqAAgAAAATAP4ABAABAAAAKwIAAAIBAwABAAAAAQA+gAAABwBAwABAAAAAQAAACIAAAAAQAAAMgAAAABAAAA...   SUkqAAgAAAATAP4ABAABAAAAKwIAAAIBAwABAAAAAQA+gAAABwBAwABAAAAAQAAACIAAAAAQAAAMgAAAABAAAA...
772740504   SUkqAAgAAAATAP4ABAABAAAAKwIAAAIBAwABAAAAAQA+gAAABwBAwABAAAAAQAAACIAAAAAQAAAMgAAAABAAAA...   SUkqAAgAAAATAP4ABAABAAAAKwIAAAIBAwABAAAAAQA+gAAABwBAwABAAAAAQAAACIAAAAAQAAAMgAAAABAAAA...
772740503   SUkqAAgAAAATAP4ABAABAAAAKwIAAAIBAwABAAAAAQA+gAAABwBAwABAAAAAQAAACIAAAAAQAAAMgAAAABAAAA...   SUkqAAgAAAATAP4ABAABAAAAKwIAAAIBAwABAAAAAQA+gAAABwBAwABAAAAAQAAACIAAAAAQAAAMgAAAABAAAA...
772740502   SUkqAAgAAAATAP4ABAABAAAAKwIAAAIBAwABAAAAAQA+gAAABwBAwABAAAAAQAAACIAAAAAQAAAMgAAAABAAAA...   SUkqAAgAAAATAP4ABAABAAAAKwIAAAIBAwABAAAAAQA+gAAABwBAwABAAAAAQAAACIAAAAAQAAAMgAAAABAAAA...
772740501   SUkqAAgAAAATAP4ABAABAAAAKwIAAAIBAwABAAAAAQA+gAAABwBAwABAAAAAQAAACIAAAAAQAAAMgAAAABAAAA...   SUkqAAgAAAATAP4ABAABAAAAKwIAAAIBAwABAAAAAQA+gAAABwBAwABAAAAAQAAACIAAAAAQAAAMgAAAABAAAA...
772740500   SUkqAAgAAAATAP4ABAABAAAAKwIAAAIBAwABAAAAAQA+gAAABwBAwABAAAAAQAAACIAAAAAQAAAMgAAAABAAAA...   SUkqAAgAAAATAP4ABAABAAAAKwIAAAIBAwABAAAAAQA+gAAABwBAwABAAAAAQAAACIAAAAAQAAAMgAAAABAAAA...

有人可以帮助我以良好的表现方式完成这项工作。而不是循环每一个以产生结果。 有时这可以超过1000行的项目。因此,以表格形式生成输出可能需要很长时间。 感谢您查看问题并为我提供解决方案。

1 个答案:

答案 0 :(得分:0)

如果你不能将产生base64字符串的proc转换为标量值函数,我恐怕除了迭代你的行并一次生成一个值之外你无能为力