Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error Max Length 32? SQL SERVER 2005

Status
Not open for further replies.

jtrembla

ISP
Jul 6, 2006
104
US
Is this really true, the length of a stored procedure cannot be > 32 characters for SQL Server 2005

ERROR:
Msg 103, Level 15, State 2, Procedure PricingDrugIMSMappingBrandGenericUpdate, Line 8
The identifier that starts with 'PricingDrugIMSMappingBrandGenericUpdate' is too long. Maximum length is 32.

Code:
USE [DR_ForecasterTest]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [MarketForecaster].[PricingDrugIMSMappingBrandGenericUpdate]
	@PricingDrugIMSMappingID INT,
	@BrandGeneric VARCHAR(7)
    
AS 
    BEGIN

        BEGIN TRANSACTION PricingDrugIMSMappingBrandGenericUpdate;
	
        BEGIN TRY
				
			UPDATE dbo.PricingDrugIMSMapping
			SET BrandGeneric = @BrandGeneric 
			WHERE PricingDrugIMSMappingID = @PricingDrugIMSMappingID

        END TRY

        BEGIN CATCH
			-- Error information is always stored to be referenced later in the
			-- event other errors are thrown while trying to resolve them.
            DECLARE @ErrNumber int,
                @ErrSeverity tinyint,
                @ErrState smallint,
                @ErrProcName nvarchar(128),
                @ErrLineNumber int,
                @ErrMessage nvarchar(4000) ;

            SELECT  @ErrNumber = ERROR_NUMBER(),
                    @ErrSeverity = ERROR_SEVERITY(),
                    @ErrState = ERROR_STATE(),
                    @ErrProcName = OBJECT_NAME(@@PROCID),
                    @ErrLineNumber = ERROR_LINE(),
                    @ErrMessage = ERROR_MESSAGE() ;
			
            ROLLBACK TRANSACTION PricingDrugIMSMappingBrandGenericUpdate ;
			-- If the error is not gracefully handled, we will raise the error, log
			-- it in the Application Event Log and return the Error Number as the 
			-- return value.
			-- Default RAISERROR
            RAISERROR ( 101211299, 16, 1, @ErrNumber, @ErrSeverity, @ErrState,
                @ErrProcName, @ErrLineNumber, @ErrMessage ) ;
            RETURN 101211299 ;
        END CATCH

        COMMIT TRANSACTION PricingDrugIMSMappingBrandGenericUpdate ;

        RETURN ;
    END
 
No. The name of a stored procedure is not limited to 32 characters. Perhaps the problem is the name of your transaction.

Code:
USE [DR_ForecasterTest]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [MarketForecaster].[PricingDrugIMSMappingBrandGenericUpdate]
    @PricingDrugIMSMappingID INT,
    @BrandGeneric VARCHAR(7)
    
AS 
    BEGIN

        BEGIN TRANSACTION [!]SmallerNameHere[/!];
    
        BEGIN TRY
                
            UPDATE dbo.PricingDrugIMSMapping
            SET BrandGeneric = @BrandGeneric 
            WHERE PricingDrugIMSMappingID = @PricingDrugIMSMappingID

        END TRY

        BEGIN CATCH
            -- Error information is always stored to be referenced later in the
            -- event other errors are thrown while trying to resolve them.
            DECLARE @ErrNumber int,
                @ErrSeverity tinyint,
                @ErrState smallint,
                @ErrProcName nvarchar(128),
                @ErrLineNumber int,
                @ErrMessage nvarchar(4000) ;

            SELECT  @ErrNumber = ERROR_NUMBER(),
                    @ErrSeverity = ERROR_SEVERITY(),
                    @ErrState = ERROR_STATE(),
                    @ErrProcName = OBJECT_NAME(@@PROCID),
                    @ErrLineNumber = ERROR_LINE(),
                    @ErrMessage = ERROR_MESSAGE() ;
            
            ROLLBACK TRANSACTION [!]SmallerNameHere[/!];
            -- If the error is not gracefully handled, we will raise the error, log
            -- it in the Application Event Log and return the Error Number as the 
            -- return value.
            -- Default RAISERROR
            RAISERROR ( 101211299, 16, 1, @ErrNumber, @ErrSeverity, @ErrState,
                @ErrProcName, @ErrLineNumber, @ErrMessage ) ;
            RETURN 101211299 ;
        END CATCH

        COMMIT TRANSACTION [!]SmallerNameHere[/!];

        RETURN ;
    END

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Just for clarity/completeness...

[tt][blue]Msg 103, Level 15, State 2, Procedure PricingDrugIMSMappingBrandGenericUpdate, [!]Line 8[/!][/blue][/tt]

When you see an error message with a line number, it can seem a little misleading, until you understand it. You see, GO separates your query window in to 'sections'. The error line refers to the line within the section.

Code:
[green]Line 1[/green]USE [DR_ForecasterTest]
GO
[green]Line 1[/green]SET ANSI_NULLS ON
GO
[green]Line 1[/green]SET QUOTED_IDENTIFIER ON
GO
[green]Line 1[/green]CREATE PROCEDURE [MarketForecaster].[PricingDrugIMSMappingBrandGenericUpdate]
[green]Line 2[/green]    @PricingDrugIMSMappingID INT,
[green]Line 3[/green]    @BrandGeneric VARCHAR(7)
[green]Line 4[/green]    
[green]Line 5[/green]AS 
[green]Line 6[/green]    BEGIN
[green]Line 7[/green]
[!]Line 8[/!]        BEGIN TRANSACTION PricingDrugIMSMappingBrandGenericUpdate;
    
        BEGIN TRY

Make sense?

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top