存储过程参数中的SQL Server Nvarchar(MAX)可变长度问题

时间:2014-10-29 06:08:26

标签: c# sql-server sql-server-2008

我在SQL Server 2008数据库中创建了一个存储过程,其参数变量类型为Nvarchar(MAX),并且从C#代码我传递的字符串长度超过4000个字符。由于它将该字符串截断为4000,因此无法成功执行该过程。

那么,有没有办法扩展这个限制?

我已通过参数

传递了以下字符串
@WhereClause = N' ((CHARINDEX('',137,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1112,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',138,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1112,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',139,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1112,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',140,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1112,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',141,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1112,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',142,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1112,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',143,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1112,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',144,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1112,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',145,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1112,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',146,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1112,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',147,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1112,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',438,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1112,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',439,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1112,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',440,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1112,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',784,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1112,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',845,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1112,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',1028,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1112,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',1076,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1112,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',1081,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1112,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',1114,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1112,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',1122,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1112,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',1129,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1112,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',1241,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1112,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',1432,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1112,'','',''+ Edu +'','') > 0 ) ) OR ((CHARINDEX('',137,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1111,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',138,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1111,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',139,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1111,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',140,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1111,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',141,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1111,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',142,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1111,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',143,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1111,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',144,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1111,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',145,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1111,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',146,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1111,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',147,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1111,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',438,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1111,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',439,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1111,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',440,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1111,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',784,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1111,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',845,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1111,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',1028,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1111,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',1076,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1111,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',1081,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1111,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',1114,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1111,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',1122,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1111,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',1129,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1111,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',1241,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1111,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',1432,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1111,'','',''+ Edu +'','') > 0 ) ) OR ((CHARINDEX('',137,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1113,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',138,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1113,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',139,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1113,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',140,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1113,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',141,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1113,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',142,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1113,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',143,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1113,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',144,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1113,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',145,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1113,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',146,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1113,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',147,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1113,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',438,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1113,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',439,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1113,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',440,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1113,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',784,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1113,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',845,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1113,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',1028,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1113,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',1076,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1113,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',1081,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1113,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',1114,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1113,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',1122,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1113,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',1129,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1113,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',1241,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1113,'','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',1432,'','',''+ Edu +'','') > 0 AND  CHARINDEX('',1113,'','',''+ Edu +'','') > 0 ) )',
    @WhereClauseEduName = N' ((CHARINDEX('',''''B.Com.'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Data Entry Operator'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Accounts / Audit'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Data Entry Operator'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Banking'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Data Entry Operator'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Comp. Science'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Data Entry Operator'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Transport'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Data Entry Operator'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Cotton'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Data Entry Operator'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Business Maths'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Data Entry Operator'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Co-operation'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Data Entry Operator'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Communication'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Data Entry Operator'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Public Finance'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Data Entry Operator'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Business Finance'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Data Entry Operator'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Book-keeping'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Data Entry Operator'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Co-operative Management'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Data Entry Operator'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Computer Management'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Data Entry Operator'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com.ALL'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Data Entry Operator'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. With Costing'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Data Entry Operator'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Comp.Application '''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Data Entry Operator'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Office Management & S.P.'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Data Entry Operator'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Buisness Management'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Data Entry Operator'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Advan.Statistics'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Data Entry Operator'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Statt.'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Data Entry Operator'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Insurance'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Data Entry Operator'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In A/c & Finance'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Data Entry Operator'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.COM. IN MARKETING'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Data Entry Operator'''','','',''+ Edu +'','') > 0 ) ) OR ((CHARINDEX('',''''B.Com.'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Accounts / Audit'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Banking'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Comp. Science'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Transport'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Cotton'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Business Maths'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Co-operation'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Communication'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Public Finance'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Business Finance'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Book-keeping'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Co-operative Management'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In ''Computer Management'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com.ALL'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. With Costing'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Comp.Application '''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Office Management & S.P.'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Buisness Management'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Advan.Statistics'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Statt.'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Insurance'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In A/c & Finance'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.COM. IN MARKETING'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer'''','','',''+ Edu +'','') > 0 ) ) OR ((CHARINDEX('',''''B.Com.'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer Programming'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Accounts / Audit'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer Programming'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Banking'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer Programming'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Comp. Science'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer Programming'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Transport'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer Programming'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Cotton'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer Programming'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Business Maths'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer Programming'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Co-operation'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer Programming'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Communication'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer Programming'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Public Finance'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer Programming'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Business Finance'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer Programming'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Book-keeping'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer Programming'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Co-operative Management'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer Programming'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Computer Management'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer Programming'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com.ALL'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer Programming'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. With Costing'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer Programming'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Comp.Application '''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer Programming'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Office Management & S.P.'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer Programming'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Buisness Management'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer Programming'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Advan.Statistics'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer Programming'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Statt.'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer Programming'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In Insurance'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer Programming'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.Com. In A/c & Finance'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer Programming'''','','',''+ Edu +'','') > 0 ) OR (CHARINDEX('',''''B.COM. IN MARKETING'''','','',''+ Edu +'','') > 0 AND  CHARINDEX('',''''Computer Programming'''','','',''+ Edu +'','') > 0 ) )',
    @AreaWhereClause = N' AND candidates.DistrictId = 14',
    @VacId = 84,
    @VacancyBookNo = N'141201400049',
    @IsView = 0

然后在SP中我打印变量@WhereClauseEduName它给了我以下结果

 ((CHARINDEX(',''B.Com.'',',','+ Edu +',') > 0 AND  CHARINDEX(',''Data Entry Operator'',',','+ Edu +',') > 0 ) OR (CHARINDEX(',''B.Com. In Accounts / Audit'',',','+ Edu +',') > 0 AND  CHARINDEX(',''Data Entry Operator'',',','+ Edu +',') > 0 ) OR (CHARINDEX(',''B.Com. In Banking'',',','+ Edu +',') > 0 AND  CHARINDEX(',''Data Entry Operator'',',','+ Edu +',') > 0 ) OR (CHARINDEX(',''B.Com. In Comp. Science'',',','+ Edu +',') > 0 AND  CHARINDEX(',''Data Entry Operator'',',','+ Edu +',') > 0 ) OR (CHARINDEX(',''B.Com. In Transport'',',','+ Edu +',') > 0 AND  CHARINDEX(',''Data Entry Operator'',',','+ Edu +',') > 0 ) OR (CHARINDEX(',''B.Com. In Cotton'',',','+ Edu +',') > 0 AND  CHARINDEX(',''Data Entry Operator'',',','+ Edu +',') > 0 ) OR (CHARINDEX(',''B.Com. In Business Maths'',',','+ Edu +',') > 0 AND  CHARINDEX(',''Data Entry Operator'',',','+ Edu +',') > 0 ) OR (CHARINDEX(',''B.Com. In Co-operation'',',','+ Edu +',') > 0 AND  CHARINDEX(',''Data Entry Operator'',',','+ Edu +',') > 0 ) OR (CHARINDEX(',''B.Com. In Communication'',',','+ Edu +',') > 0 AND  CHARINDEX(',''Data Entry Operator'',',','+ Edu +',') > 0 ) OR (CHARINDEX(',''B.Com. In Public Finance'',',','+ Edu +',') > 0 AND  CHARINDEX(',''Data Entry Operator'',',','+ Edu +',') > 0 ) OR (CHARINDEX(',''B.Com. In Business Finance'',',','+ Edu +',') > 0 AND  CHARINDEX(',''Data Entry Operator'',',','+ Edu +',') > 0 ) OR (CHARINDEX(',''B.Com. In Book-keeping'',',','+ Edu +',') > 0 AND  CHARINDEX(',''Data Entry Operator'',',','+ Edu +',') > 0 ) OR (CHARINDEX(',''B.Com. In Co-operative Management'',',','+ Edu +',') > 0 AND  CHARINDEX(',''Data Entry Operator'',',','+ Edu +',') > 0 ) OR (CHARINDEX(',''B.Com. In Computer Management'',',','+ Edu +',') > 0 AND  CHARINDEX(',''Data Entry Operator'',',','+ Edu +',') > 0 ) OR (CHARINDEX(',''B.Com.ALL'',',','+ Edu +',') > 0 AND  CHARINDEX(',''Data Entry Operator'',',','+ Edu +',') > 0 ) OR (CHARINDEX(',''B.Com. With Costing'',',','+ Edu +',') > 0 AND  CHARINDEX(',''Data Entry Operator'',',','+ Edu +',') > 0 ) OR (CHARINDEX(',''B.Com. In Comp.Application '',',','+ Edu +',') > 0 AND  CHARINDEX(',''Data Entry Operator'',',','+ Edu +',') > 0 ) OR (CHARINDEX(',''B.Com. In Office Management & S.P.'',',','+ Edu +',') > 0 AND  CHARINDEX(',''Data Entry Operator'',',','+ Edu +',') > 0 ) OR (CHARINDEX(',''B.Com. In Buisness Management'',',','+ Edu +',') > 0 AND  CHARINDEX(',''Data Entry Operator'',',','+ Edu +',') > 0 ) OR (CHARINDEX(',''B.Com. In Advan.Statistics'',',','+ Edu +',') > 0 AND  CHARINDEX(',''Data Entry Operator'',',','+ Edu +',') > 0 ) OR (CHARINDEX(',''B.Com. In Statt.'',',','+ Edu +',') > 0 AND  CHARINDEX(',''Data Entry Operator'',',','+ Edu +',') > 0 ) OR (CHARINDEX(',''B.Com. In Insurance'',',','+ Edu +',') > 0 AND  CHARINDEX(',''Data Entry Operator'',',','+ Edu +',') > 0 ) OR (CHARINDEX(',''B.Com. In A/c & Finance'',',','+ Edu +',') > 0 AND  CHARINDEX(',''Data Entry Operator'',',','+ Edu +',') > 0 ) OR (CHARINDEX(',''B.COM. IN MARKETING'',',','+ Edu +',') > 0 AND  CHARINDEX(',''Data Entry Operator'',',','+ Edu +',') > 0 ) ) OR ((CHARINDEX(',''B.Com.'',',','+ Edu +',') > 0 AND  CHARINDEX(',''Computer'',',','+ Edu +',') > 0 ) OR (CHARINDEX(',''B.Com. In Accounts / Audit'',',','+ Edu +',') > 0 AND  CHARINDEX(',''Computer'',',','+ Edu +',') > 0 ) OR (CHARINDEX(',''B.Com. In Banking'',',','+ Edu +',') > 0 AND  CHARINDEX(',''Computer'',',','+ Edu +',') > 0 ) OR (CHARINDEX(',''B.Com. In Comp. Science'',',','+ Edu +',') > 0 AND  CHARINDEX(',''Computer'',',','+ Edu +',') > 0 ) OR (CHARINDEX(',''B.Com. In Transport'',',','+ Edu +',') > 0 AND  CHARINDEX(',''Computer'',',','+ Edu +',') > 0 ) OR (CHARINDEX(',''B.Com. In Cotton'',',','+ Edu +',') > 0 AND  CHARINDEX(',''Computer'',',','+ Edu +',') > 0 ) OR (CHARINDEX(',''B.Com. In Business Maths'',',','+ Edu +',') > 0 AND  CHARINDEX(',''Computer'',',','+ Edu +',') > 0 ) OR (CHARINDEX(',''B.Com. In Co-operation'',',','+ Edu +',') > 0 AND  CHARINDEX(',''Computer'',',','+ Edu +',') > 0 ) OR

通过查看输出,我只能看到前4000个字符。那是我的动态查询运行不正常。

1 个答案:

答案 0 :(得分:1)

SQL Server中的Print命令对NVarchar有4000个字符限制,对Varchar有8000个字符限制。请在备注部分http://msdn.microsoft.com/en-nz/library/ms176047.aspx

中查看有关MSDN的更多详细信息

看起来你可以通过手动编写一些代码来一次打印输出卡盘来克服这个问题。这个link有一个解决方案可以做到这一点,也可以打破换行符。

这是stackoverflow link

的另一个解决方案