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

  • Home
  • SEARCH
  • 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 175633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T13:44:01+00:00 2026-05-11T13:44:01+00:00

I am presenting to a final authority evaluation scores for employees. Each row is

  • 0

I am presenting to a final authority evaluation scores for employees. Each row is an employee’s data and since the categories to be evaluated can change from period to period the column names cannot be hardcoded in the Stored Procedures. I have already devised the following solution.

1 Create a temp table
2 Dynamically use the Alter Table command to add all applicable columns (Stored in @ColumnNames)
3 Use Dynamic SQL inside a cursor to write an insert for each employee that gets the correct scores (IE N employees means N inserts)

(SELECT @ECMScores = COALESCE(@ECMScores + ',', '') + CAST(EIS.ECMScore AS NVARCHAR(1000)) (FROM...))  SET @SQLString = ''  SET @SQLString = @SQLString + 'INSERT INTO      #ResultSet (' SET @SQLString = @SQLString + 'EvaluationScoreID,' SET @SQLString = @SQLString + 'EmployeeID,' SET @SQLString = @SQLString + 'EmployeeName,' SET @SQLString = @SQLString + @ColumnNames SET @SQLString = @SQLString + ') '   SET @SQLString = @SQLString + 'VALUES (' SET @SQLString = @SQLString + ''+CAST(@EvaluationScoreID AS NVARCHAR(MAX))+',' SET @SQLString = @SQLString + ''+CAST(@EmployeeID AS NVARCHAR(MAX))+',' SET @SQLString = @SQLString + '''+@EmployeeName+'',' SET @SQLString = @SQLString + @ECMScores SET @SQLString = @SQLString + ')'  EXECUTE sp_executesql   @SQLString 

The problem is it takes approx 1 second for every 100 employees. This quickly becomes unacceptable…

Does anyone have any better ideas on how to proceed? Removing the cursor (obviously), and using one insert (Perhaps Select into) is my first idea perhaps reading from a dynamically created XML variable…

Thanks,

  • 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. 2026-05-11T13:44:02+00:00Added an answer on May 11, 2026 at 1:44 pm

    don’t store data in the schema

    create tables like this:

    Assignment AssignmentID   int not null primary key identity(1,1) AssignmentName varchar(50)  not null AssignmentDate datetime not null etc..  Score ScoreID       int not null primary key identity(1,1) EmployeeID    int not null AssignmentID  int not null ScoreValue    int not null  Employee EmployeeID    int not null primary key identity(1,1) EmployeeName  varhar(100) not null etc.. 

    you can now create ‘assignments’ and insert ‘scores’ without building dynamic queries because your columns always change. your columns will now stay the same and the data will change.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am presenting a list of managed objects where each has a timeStamp property.
When presenting preformatted text on the web (e.g. code samples), line wrapping can be
I'm presenting data in a matrix (a crosstab). To ensure that all rows are
Web presenting a website in a UIWebView, the user can touch links. When testing
I have an ItemsControl presenting TextBlocks, with a Separator at the bottom of each
I am embedding some QTableWidget(s) recursively inside of each other. The final GUI will
I am presenting a tableview where users can select in which calendar to put
When presenting a modal form sheet view controller on the iPad the remainder of
I'm presenting a problem my professor showed in class, with my O(n*log(n)) solution: Given
I am presenting user with a alert dialog which contains 2 items, I want

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.