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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:26:43+00:00 2026-06-17T06:26:43+00:00

I was creating a column that will give a me random number but I

  • 0

I was creating a column that will give a me random number but I was getting some errors.

CREATE TABLE tblBookInfo
(
AccessionNumber NVARCHAR(MAX)
 RandomNumber NVARCHAR(10);
 AccNo NVARCHAR(MAX)
 @Upper INT;
 @Lower INT

SET @Lower = 1
SET @Upper = 9999

Select @RandomNumber = Round (((@Upper - @Lower -1)* RAND() + @Lower), 0)

SET @AccNo = 'LIBBOOKS' + RandomNumber
SELECT @AccNo

Set AccessionNumber = AccNo
)

ERRORS:

Incorrect syntax near 'RandomNumber'.
Must declare the scalar variable "@Lower".
Must declare the scalar variable "@Upper".
Must declare the scalar variable "@Upper".
Must declare the scalar variable "@AccNo".
Must declare the scalar variable "@AccNo".

tHank you for your help 😀

  • 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-06-17T06:26:44+00:00Added an answer on June 17, 2026 at 6:26 am

    Its not very clear what you are trying to accomplish, but here is my interpretation of your code in the correct T-SQL syntax.
    I’m not prepared to guess what you’re trying to do below that.

    CREATE TABLE tblBookInfo 
    (   
        AccessionNumber NVARCHAR(MAX),
        RandomNumber NVARCHAR(10), 
        AccNo NVARCHAR(MAX) 
    )
    DECLARE @Upper          INT, 
            @Lower          INT,
            @RandomNumber   INT
    
    SET @Lower = 1 SET @Upper = 9999
    
    SELECT @RandomNumber = Round (((@Upper - @Lower -1)* RAND() + @Lower), 0)
    
    SELECT @RandomNumber
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I'm creating a table foo with a column bar that should be
I am creating a website that will allow people to make lists, but I'm
I'm using Microsoft SQL Server 2005. I'm creating a random record generator that will
I want to create a column element_type in a table (called discussion ) that
I'm currently creating a SP that will copy information from table a into table
I'm creating a table with column of INT(20). Whenever I submit a value greater
I'm creating a 'similar items' link table. i have a 2 column table. both
I'm creating a DB that will hold products with several height columns (in meters,
I am creating a website that will have articles; each article will have comments.
I'm creating an object hierarchy that is representing a table that is draw on

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.