10月 21, 2013

SQL-stored procedure

ALTER PROCEDURE [dbo].[spss] 
    -- Add the parameters for the stored procedure here
    @c2 nvarchar(50),
    @c3 nvarchar(50) output
    --DECLARE @oo nchar(20) = 'Transaction1';
AS
BEGIN TRY
BEGIN TRAN m1
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    -- SET NOCOUNT ON;
    Insert into stu(stu,c1,c2) values(121,'hello',@c2)
    update the set t1='www' where the = 102
    -- Insert statements for procedure here
    set @c3 = @c2
    SELECT * FROM [stu]
    
COMMIT TRAN m1
return 999
END TRY
BEGIN CATCH
    IF @@TRANCOUNT > 0
     ROLLBACK TRAN m1
     -- Return the error information.
  DECLARE @ErrorMessage nvarchar(4000),  @ErrorSeverity int;
  SELECT @ErrorMessage = ERROR_MESSAGE(),@ErrorSeverity = ERROR_SEVERITY();
  RAISERROR(@ErrorMessage, @ErrorSeverity, 1);
END CATCH

沒有留言: