大力帮忙,存储过程问题,有TEXT字段类型的记录不能UNION
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
ALTER PROCEDURE dh_GetQueryResult (@TableName varchar(100),@QueryString varchar(100),@StrCondition varchar(100))
AS declare @Ssql varchar(8000) DECLARE Query_cursor CURSOR FOR
Select S.Name from SysColumns S inner join SysObjects O on S.ID=O.ID Where O.Name=@TableName
declare @FName varchar(100)
open Query_cursor
fetch Query_cursor into @FName
Set @Ssql='(Select * from '+@TableName +' Where Cast ('+@FName +' as varchar) like ''%' +@QueryString +'%'''+@Strcondition+')'
fetch next from Query_cursor into @FName
while @@fetch_status=0
begin
set @Ssql=@Ssql+( ' union (Select * from '+@TableName +' Where Cast ('+@FName +' as varchar) like ''%' +@QueryString+'%'''+@Strcondition+')')
fetch next from Query_cursor into @FName
end
close Query_cursor
deallocate Query_cursor
Exec(@Ssql)
return
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
其中有几个字段是TEXT类型的,任一查询都没问题,UNION了以后就说DISTINCT不能用于TEXT,IMAGE字段,
应该是对UNION的记录集自动DISTINCT了,急,谢谢