Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 689951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:23:07+00:00 2026-05-14T02:23:07+00:00

I have an SQL CREATE PROCEDURE statement that runs perfectly in my local SQL

  • 0

I have an SQL CREATE PROCEDURE statement that runs perfectly in my local SQL Server, but cannot be recreated in production environment. The error message I get in production is Msg 102, Level 15, State 1, Incorrect syntax near ‘=’.

It is a pretty big query and I don’t want to annoy StackOverflow users, but I simply can’t find a solution. If only you could point me out what settings I could check in the production server in order to enable running the code… I must be using some kind of syntax or something that is conflicting with some setting in production. This PROCEDURE was already registered in production before, but when I ran a DROP – CREATE PROCEDURE today, the server was able to drop the procedure, but not to recreate it.

I will paste the code below. Thank you!

===============

USE [Enorway]
GO

/****** Object:  StoredProcedure [dbo].[Spel_CM_ChartsUsersTotals]    Script Date: 03/17/2010 11:59:57 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROC [dbo].[Spel_CM_ChartsUsersTotals]
    @IdGroup int,
    @IdAssessment int,
    @UserId int
AS
SET NOCOUNT ON

DECLARE @RequiredColor varchar(6)
SET @RequiredColor = '3333cc'

DECLARE @ManagersColor varchar(6)
SET @ManagersColor = '993300'

DECLARE @GroupColor varchar(6)
SET @GroupColor = 'ff0000'

DECLARE @SelfColor varchar(6)
SET @SelfColor = '336600'

DECLARE @TeamColor varchar(6)
SET @TeamColor = '993399'

DECLARE @intMyCounter tinyint
DECLARE @intManagersPosition tinyint
DECLARE @intGroupPosition tinyint
DECLARE @intSelfPosition tinyint
DECLARE @intTeamPosition tinyint
SET @intMyCounter = 1


-- Table that will hold the subtotals...
DECLARE @tblTotalsSource table
(
    IdCompetency int,
    CompetencyName nvarchar(200),
    FunctionRequiredLevel float,
    ManagersAverageAssessment float,
    SelfAssessment float,
    GroupAverageAssessment float,
    TeamAverageAssessment float
)

INSERT INTO @tblTotalsSource
(
    IdCompetency,
    CompetencyName,
    FunctionRequiredLevel,
    ManagersAverageAssessment,
    SelfAssessment,
    GroupAverageAssessment,
    TeamAverageAssessment
)

SELECT
    e.[IdCompetency],
    dbo.replaceAccentChar(e.[Name]) AS CompetencyName,
    (i.[LevelNumber]) AS FunctionRequiredLevel,
    (
        SELECT
            ROUND(avg(CAST(ac.[LevelNumber] AS float)),0)
        FROM
            Spel_CM_AssessmentsData aa
            INNER JOIN Spel_CM_CompetenciesLevels ab ON aa.[IdCompetencyLevel] = ab.[IdCompetencyLevel]
            INNER JOIN Spel_CM_Levels ac ON ab.[IdLevel] = ac.[IdLevel]
            INNER JOIN Spel_CM_AssessmentsEvents ad ON aa.[IdAssessmentEvent] = ad.[IdAssessmentEvent]
        WHERE
            aa.[EvaluatedUserId] = @UserId AND
            aa.[AssessmentType] = 't' AND
            aa.[IdGroup] = @IdGroup AND
            ab.[IdCompetency] = e.[IdCompetency] AND
            ad.[IdAssessment] = @IdAssessment
    ) AS ManagersAverageAssessment,
    (
        SELECT 
            bc.[LevelNumber]
        FROM
            Spel_CM_AssessmentsData ba
            INNER JOIN Spel_CM_CompetenciesLevels bb ON ba.[IdCompetencyLevel] = bb.[IdCompetencyLevel]
            INNER JOIN Spel_CM_Levels bc ON bb.[IdLevel] = bc.[IdLevel]
            INNER JOIN Spel_CM_AssessmentsEvents bd ON ba.[IdAssessmentEvent] = bd.[IdAssessmentEvent]
        WHERE
            ba.[EvaluatedUserId] = @UserId AND
            ba.[AssessmentType] = 's' AND
            ba.[IdGroup] = @IdGroup AND
            bb.[IdCompetency] = e.[IdCompetency] AND
            bd.[IdAssessment] = @IdAssessment
    ) AS SelfAssessment,
    (
        SELECT
            ROUND(avg(CAST(cc.[LevelNumber] AS float)),0)
        FROM
            Spel_CM_AssessmentsData ca
            INNER JOIN Spel_CM_CompetenciesLevels cb ON ca.[IdCompetencyLevel] = cb.[IdCompetencyLevel]
            INNER JOIN Spel_CM_Levels cc ON cb.[IdLevel] = cc.[IdLevel]
            INNER JOIN Spel_CM_AssessmentsEvents cd ON ca.[IdAssessmentEvent] = cd.[IdAssessmentEvent]
        WHERE
            ca.[EvaluatedUserId] = @UserId AND
            ca.[AssessmentType] = 'g' AND
            ca.[IdGroup] = @IdGroup AND
            cb.[IdCompetency] = e.[IdCompetency] AND
            cd.[IdAssessment] = @IdAssessment
    ) AS GroupAverageAssessment,
    (
        SELECT
            ROUND(avg(CAST(dc.[LevelNumber] AS float)),0)
        FROM
            Spel_CM_AssessmentsData da
            INNER JOIN Spel_CM_CompetenciesLevels db ON da.[IdCompetencyLevel] = db.[IdCompetencyLevel]
            INNER JOIN Spel_CM_Levels dc ON db.[IdLevel] = dc.[IdLevel]
            INNER JOIN Spel_CM_AssessmentsEvents dd ON da.[IdAssessmentEvent] = dd.[IdAssessmentEvent]
        WHERE
            da.[EvaluatedUserId] = @UserId AND
            da.[AssessmentType] = 'm' AND
            da.[IdGroup] = @IdGroup AND
            db.[IdCompetency] = e.[IdCompetency] AND
            dd.[IdAssessment] = @IdAssessment
    ) AS TeamAverageAssessment
FROM
    Spel_CM_AssessmentsData a
    INNER JOIN Spel_CM_AssessmentsEvents c ON a.[IdAssessmentEvent] = c.[IdAssessmentEvent]
    INNER JOIN Spel_CM_CompetenciesLevels d ON a.[IdCompetencyLevel] = d.[IdCompetencyLevel]
    INNER JOIN Spel_CM_Competencies e ON d.[IdCompetency] = e.[IdCompetency]
    INNER JOIN Spel_CM_Levels f ON d.[IdLevel] = f.[IdLevel]
    -- This will link with user's assigned functions
    INNER JOIN Spel_CM_FunctionsCompetenciesLevels g ON a.[IdFunction] = g.[IdFunction]
    INNER JOIN Spel_CM_CompetenciesLevels h ON g.[IdCompetencyLevel] = h.[IdCompetencyLevel] AND e.[IdCompetency] = h.[IdCompetency]
    INNER JOIN Spel_CM_Levels i ON h.[IdLevel] = i.[IdLevel]
WHERE
    (NOT c.[EndDate] IS NULL) AND
    a.[EvaluatedUserId] = @UserId AND
    c.[IdAssessment] = @IdAssessment AND
    a.[IdGroup] = @IdGroup
GROUP BY
    e.[IdCompetency],
    e.[Name],
    i.[LevelNumber]
ORDER BY
    e.[Name] ASC


-- This will define the position of each element (managers, group, self and team)
SELECT @intManagersPosition = @intMyCounter FROM @tblTotalsSource WHERE NOT ManagersAverageAssessment IS NULL
IF IsNumeric(@intManagersPosition) = 1 BEGIN SELECT @intMyCounter += 1 END

SELECT @intGroupPosition = @intMyCounter FROM @tblTotalsSource WHERE NOT GroupAverageAssessment IS NULL
IF IsNumeric(@intGroupPosition) = 1 BEGIN SELECT @intMyCounter += 1 END

SELECT @intSelfPosition = @intMyCounter FROM @tblTotalsSource WHERE NOT SelfAssessment IS NULL
IF IsNumeric(@intSelfPosition) = 1 BEGIN SELECT @intMyCounter += 1 END

SELECT @intTeamPosition = @intMyCounter FROM @tblTotalsSource WHERE NOT TeamAverageAssessment IS NULL


-- This will render the final table for the end user. The tabe will flatten some of the numbers to allow them to be prepared for Google Graphics.
SELECT
    SUBSTRING( 
        (
            SELECT
                ( '|' + REPLACE(ma.[CompetencyName],' ','+'))
            FROM
                @tblTotalsSource ma
            ORDER BY
                ma.[CompetencyName] DESC
            FOR XML PATH('')
        ), 2, 1000) AS 'CompetenciesNames',
    SUBSTRING(
        (
            SELECT
                ( ',' + REPLACE(ra.[FunctionRequiredLevel]*10,' ','+'))
            FROM
                @tblTotalsSource ra
            FOR XML PATH('')
        ), 2, 1000) AS 'FunctionRequiredLevel',
    SUBSTRING( 
        (
            SELECT
                ( ',' + CAST(na.[ManagersAverageAssessment]*10 AS nvarchar(10)))
            FROM
                @tblTotalsSource na
            FOR XML PATH('')
        ), 2, 1000) AS 'ManagersAverageAssessment',
    SUBSTRING( 
        (
            SELECT
                ( ',' + CAST(oa.[GroupAverageAssessment]*10 AS nvarchar(10)))
            FROM
                @tblTotalsSource oa
            FOR XML PATH('')
        ), 2, 1000) AS 'GroupAverageAssessment',
    SUBSTRING( 
        (
            SELECT
                ( ',' + CAST(pa.[SelfAssessment]*10 AS nvarchar(10)))
            FROM
                @tblTotalsSource pa
            FOR XML PATH('')
        ), 2, 1000) AS 'SelfAssessment',
    SUBSTRING( 
        (
            SELECT
                ( ',' + CAST(qa.[TeamAverageAssessment]*10 AS nvarchar(10)))
            FROM
                @tblTotalsSource qa
            FOR XML PATH('')
        ), 2, 1000) AS 'TeamAverageAssessment',
    SUBSTRING( 
        (
            SELECT
                ( '|t++' + CAST([FunctionRequiredLevel] AS varchar(10)) + ',' + @RequiredColor + ',0,' + CAST(ROW_NUMBER() OVER(ORDER BY CompetencyName) - 1 AS varchar(2)) + ',9')
            FROM
                @tblTotalsSource
            FOR XML PATH('')
        ), 2, 1000) AS 'FunctionRequiredAverageLabel',
    SUBSTRING( 
        (
            SELECT
                ( '|t++' + CAST([ManagersAverageAssessment] AS varchar(10)) + ',' + @ManagersColor + ',' + CAST(@intManagersPosition AS varchar(2)) + ',' + CAST(ROW_NUMBER() OVER(ORDER BY CompetencyName) - 1 AS varchar(2)) + ',9')
            FROM
                @tblTotalsSource
            FOR XML PATH('')
        ), 2, 1000) AS 'ManagersLabel',
    SUBSTRING( 
        (
            SELECT
                ( '|t++' + CAST([GroupAverageAssessment] AS varchar(10)) + ',' + @GroupColor + ',' + CAST(@intGroupPosition AS varchar(2)) + ',' + CAST(ROW_NUMBER() OVER(ORDER BY CompetencyName) - 1 AS varchar(2)) + ',9')
            FROM
                @tblTotalsSource
                FOR XML PATH('')
        ), 2, 1000) AS 'GroupLabel',
    SUBSTRING( 
        (
            SELECT
                ( '|t++' + CAST([SelfAssessment] AS varchar(10)) + ',' + @SelfColor + ',' + CAST(@intSelfPosition AS varchar(2)) + ',' + CAST(ROW_NUMBER() OVER(ORDER BY CompetencyName) - 1 AS varchar(2)) + ',9')
            FROM
                @tblTotalsSource
            FOR XML PATH('')
        ), 2, 1000) AS 'SelfLabel',
    SUBSTRING( 
        (
            SELECT
                ( '|t++' + CAST([TeamAverageAssessment] AS varchar(10)) + ',' + @TeamColor + ',' + CAST(@intTeamPosition AS varchar(2)) + ',' + CAST(ROW_NUMBER() OVER(ORDER BY CompetencyName) - 1 AS varchar(2)) + ',10')
            FROM
                @tblTotalsSource
            FOR XML PATH('')
        ), 2, 1000) AS 'TeamLabel',
        (Count(src.[IdCompetency]) * 30) + 100 AS 'ControlHeight'
FROM 
    @tblTotalsSource src


SET NOCOUNT OFF
GO
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T02:23:08+00:00Added an answer on May 14, 2026 at 2:23 am

    Search your stored procedure for instances of this string: += (you have a few of them). This combined operator is not supported by T-SQL,

    So instead of this:

    SELECT @intMyCounter += 1
    

    you will need to do this instead:

    SELECT @intMyCounter = @intMyCounter + 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.