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 109581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:05:31+00:00 2026-05-11T02:05:31+00:00

I have problem compilin this code..can anyone tell whats wrong with the syntax CREATE

  • 0

I have problem compilin this code..can anyone tell whats wrong with the syntax

CREATE PROCEDURE spGenericInsert     (         @insValueStr nvarchar(200)           @tblName nvarchar(10)      )  AS  BEGIN      DECLARE @insQueryStr nvarchar(400)     DECLARE @insPrimaryKey nvarchar(10)     DECLARE @rowCountVal integer     DECLARE @prefix nvarchar(5)       IF @tblName='HW_Master_DB'         SET @rowCountVal=(SELECT COUNT(*) FROM HW_Master_DB)     ELSE IF @TableName='SW_Master_DB'         SET @rowCountVal=(SELECT COUNT(*) FROM SW_Master_DB)     ELSE IF @TableName='INV_Allocation_DB'         SET @rowCountVal=(SELECT COUNT(*) FROM INV_Allocation_DB)     ELSE IF @TableName='REQ_Master_DB'         SET @rowCountVal=(SELECT COUNT(*) FROM REQ_Master_DB)      IF @tblName = 'DEFECT_LOG'          SET @prefix='DEF_'     ELSE IF @tblName='INV_Allocation_DB'         SET @prefix='INV_'     ELSE IF @tblName='REQ_Master_DB'         SET @prefix='REQ_'     ELSE IF @tblName='SW_Master_DB'         SET @prefix='SWI_'     ELSE IF @tblName='HW_Master_DB'         SET @prefix='HWI_'         SET @insPrimaryKey= @prefix + RIGHT(replicate('0',5)+ convert(varchar(5),@rowCountVal),5) -- returns somethin like 'DEF_00005'      SET @insQueryStr= 'INSERT INTO ' + @tblName + ' VALUES (' + @insPrimaryKey + ',' + @insValueStr + ')'      EXEC(@insQueryStr)  END 

I know about Integer Identity columns.. but i have to use a AlphaNumeric ID in the tables in inserting new values in a highly multi-user intranet system.

The records will not be deleted from the table. So problem is that of maintain synchronous insertion of records with ID field automatically generated.

Any suggestions how that can be done.

  • 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-11T02:05:31+00:00Added an answer on May 11, 2026 at 2:05 am

    I cannot immediately see what’s wrong with the syntax (the sharp eye of Jonathan Lonowski has solved that already), but there are some things wrong with the code:

    1. You create dynamic SQL, so your code is vunerable to SQL-injection attacks. Both the input parameters are used in a dangerous way. Solve this by creating a stored procedure for every table. So you don’t have to generate SQL anymore.

    2. There is no check if the table is not in the list used.

    3. Your primary key generation algorithm can/will create duplicate keys in a multi-user scenario, or if rows are deleted from the table. Solve by using an identity column or some other feature from the database you are using.

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

Sidebar

Ask A Question

Stats

  • Questions 176k
  • Answers 176k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The 0x80072020 error is related to a generic "Access Denied"… May 12, 2026 at 3:12 pm
  • Editorial Team
    Editorial Team added an answer The GMT offset of a given client is available within… May 12, 2026 at 3:12 pm
  • Editorial Team
    Editorial Team added an answer UIScrollView tries to figure out which touches to pass through… May 12, 2026 at 3:12 pm

Related Questions

I have a CUDA kernel which I'm compiling to a cubin file without any
Can anyone confirm what the standard says about the default return type of vararg
So I have a C program. And I don't think I can post any
In an application I maintain, we've encountered a problem with file descriptor limitations affecting

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.