sql server中存储过程提示错误

 

 

1、今天写存储过程是运行时总是提示如下错误:

Subquery returned more than 1 value. This is not permitted when the subquery follows =, t!=, <, <= ,>, >= or when he subquery is used as an expression.

后来我一点点的查找终于知道是哪里的问题了,下面是错误的语句:

    select * from ResultTable where charIndex(','+convert(varchar(40),CenterID)+',',','+(SELECT OrgUnitIds FROM VolunteerSearch_Filter WHERE (UserId = 1) AND (SearchType = 'report') )+',')>0

 SELECT OrgUnitIds FROM VolunteerSearch_Filter WHERE (UserId = 1) AND (SearchType = 'report') 

所获得的记录不是唯一的因此错了。

2、存储过程运行提示错误:

String or binary data would be truncated.

Warning: Null value is eliminated by an aggregate or other SET operation.

The statement has been terminated。

解决方案:这是因为某字段的长度不够造成的。增大字段的长度就可以了。

你可能感兴趣的:(SQL Server)