我創建了一個過程(使用SQL Server 2008)從image
表中檢索圖像數據,但此過程給了我一個錯誤無法比較或排序文本,ntext和圖像數據類型,除非使用IS NULL或LIKE運算符
「使用時除外的文本,ntext和圖像數據類型不能比較或排序, IS NULL或LIKE運算符」。
我的程序是這樣的:
Create procedure [dbo].[xp_GetImage]
@companyId udtId
as
begin
/*=============================================================================
* Constants
*============================================================================*/
declare
@SUCCESS smallint,
@FAILED smallint,
@ERROR_SEVERITY smallint,
@ERROR_STATE1 smallint,
@theErrorMsg nvarchar(4000),
@theErrorState int,
@chartCount int,
@provider varchar(128),
@projectCount int
select
@SUCCESS = 0,
@FAILED = -1,
@ERROR_SEVERITY = 11,
@ERROR_STATE1 = 1
begin try
-- Get the Image
select Logo, LogoName,LogoSize
from CompanyLogo
where CompanyId = @companyId
order by Logo desc
end try
begin catch
set @theErrorMsg = error_message()
set @theErrorState = error_state()
raiserror (@theErrorMsg, @ERROR_SEVERITY, @theErrorState)
return (@FAILED)
end catch
end
print 'created the procedure xp_GetImage'
go
---end of the procedure
grant EXECUTE on xp_GetImage to public
go
請幫助我。
另外:*將在未來版本的Microsoft SQL Server中刪除ntext,文本和圖像數據類型。 **避免在新開發工作中使用這些數據類型**,並計劃修改當前使用它們的應用程序。請使用nvarchar(max),varchar(max)和varbinary(max)代替。* [請參閱MSDN文檔以獲取更多信息](http://msdn.microsoft.com/zh-cn/library/ms187993.aspx) –
排序依據一個字節數組,爲什麼? – Magnus