I'm having problems with the following procedure
我遇到以下程序的问题
CREATE PROCEDURE [dbo].[Q2_05] (@Ch1 nvarchar, @Ch4 nvarchar, @globalOptionCode nvarchar)
AS
BEGIN
SET NOCOUNT ON;
SELECT [2_05].Ch1, [2_05].Ch4, [2_05].GlobalOption, [2_05].Part, [2_05].[Key]
FROM [dbo.NV300Autostructure].[2_05]
WHERE ((([2_05].Ch1)=@Ch1) AND (([2_05].Ch4)=@Ch4) AND (([2_05].GlobalOption)=@globalOptionCode));
END
when I execute it with the following parameters ('5', 'TH', '.') it returns no results, but in the process of elimination I found that modifying the conditions line and set [2_05].Ch4 explicitly to 'TH' like so:
当我用以下参数('5','TH','。')执行它时,它不返回任何结果,但在消除过程中我发现修改条件行并将[2_05] .Ch4显式设置为'TH '喜欢这样:
WHERE ((([2_05].Ch1)=@Ch1) AND (([2_05].Ch4)='TH') AND (([2_05].GlobalOption)=@globalOptionCode));
it returns a row of the database. Why is that happening?
它返回一行数据库。为什么会这样?
1 个解决方案
#1
3
You are not specifying a size for your nvarchar
parameters. The default is 1 character.
您没有为nvarchar参数指定大小。默认值为1个字符。
So the procedure is testing for [2_05].Ch4)='T'
when you use the parameters.
因此,当您使用参数时,该过程正在测试[2_05] .Ch4)='T'。
#1
3
You are not specifying a size for your nvarchar
parameters. The default is 1 character.
您没有为nvarchar参数指定大小。默认值为1个字符。
So the procedure is testing for [2_05].Ch4)='T'
when you use the parameters.
因此,当您使用参数时,该过程正在测试[2_05] .Ch4)='T'。