#sqlserver#MSSQL
sqlserver编写存储过程时,输入参数作为查询条件,什么都查不到;直接把查询内容放入查询条件 可以查询出来,感觉用变量去查询好像没有接收到输入参数一样。请帮忙解答一下:
sql如下:
alter PROC [dbo].[GetDC]
@ContainerSn VARCHAR(50)
AS
Begin
DECLARE @ContainerSn2 VARCHAR(50)
DECLARE @DCYear VARCHAR(4)
DECLARE @DCMonth VARCHAR(4)
DECLARE @DCDay VARCHAR(4)
DECLARE @DC AS VARCHAR(12)
DECLARE @CheckTime AS VARCHAR(12)
SELECT top 1 * from T_Bllb_packageOneMain_tbpom where CONTAINER_SN=@ContainerSn;
end
exec GetDC @ContainerSn= 'TP:;WO:0000008779;PN:C010A0000000125;HUE:n3hL/P54;CAT:B77;REF:0;SN:2024032000003;HUE:r3hL/P54:CAT:B77;REF:0;'
以上存储过程,查询不到任何内容。
alter PROC [dbo].[GetDC]
@ContainerSn VARCHAR(50)
AS
Begin
DECLARE @ContainerSn2 VARCHAR(50)
DECLARE @DCYear VARCHAR(4)
DECLARE @DCMonth VARCHAR(4)
DECLARE @DCDay VARCHAR(4)
DECLARE @DC AS VARCHAR(12)
DECLARE @CheckTime AS VARCHAR(12)
SELECT top 1 @ContainerSn,* from T_Bllb_packageOneMain_tbpom where CONTAINER_SN= 'TP:;WO:0000008779;PN:C010A0000000125;HUE:n3hL/P54;CAT:B77;REF:0;SN:2024032000003;HUE:r3hL/P54:CAT:B77;REF:0;';
end
exec GetDC @ContainerSn= 'TP:;WO:0000008779;PN:C010A0000000125;HUE:n3hL/P54;CAT:B77;REF:0;SN:2024032000003;HUE:r3hL/P54:CAT:B77;REF:0;'
这种方式可以查询出内容。
请帮忙解答一下。