例えば:
CREATE PROCEDURE dbo.MyProc
AS
BEGIN
SET NOCOUNT ON;
BEGIN TRY
...
DECLARE @Id INT;
-- I don't want the following line to throw and abort processing.
-- I just want @Id to remain NULL. I can add a nested TRY/CATCH, but is there
-- a better way?
SET @Id=(SELECT Id FROM MyTable WHERE ...);
...
END TRY
BEGIN CATCH
...
END CATCH;
END;
更新:明確にするために、複数の行が返される場合、@IdをNULLのままにしておきます。