DECLARE @cnt INT=0
                DECLARE @cardnonew VARCHAR(100) =@oldcardno
                DECLARE @oldcardnoA1 NVARCHAR(100) =@oldcardno+N'A1'
                DECLARE @sql NVARCHAR(MAX) =N' SELECT @num=COUNT(1)   FROM dbo.ep_CardBase WHERE ep_CardNo LIKE  ''%'+@oldcardnoA1+N'%''  AND ep_survivalstatus=778170000'
                PRINT @sql
                EXEC sp_executesql @sql, N'@num int output', @cnt OUTPUT
select @cnt