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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:04:08+00:00 2026-06-17T01:04:08+00:00

Disclaimer: I am still learning SQL so I apologize if my question comes off

  • 0

Disclaimer:
I am still learning SQL so I apologize if my question comes off as amateur-ish or is otherwise a very simple answer. I have no formal training. I am teaching myself.

The title may be a bit confusing, as I’m not entirely sure how to word this for a title.

Basically, I want to convert a column in a table thats currently VARCHAR into an INT. The column contains only numbers formatted as such:

00001
00005
02150

These are essentially ID’s which will be appended to a Name column later for other purposes. If its necessary to do so, I’d also like to know how to convert the end result INT to VARCHAR for the append portion.

Here’s what I have right now:

SELECT CONVERT(INT, LocNo)

It returns the results I expect but I think I need to somehow update the existing LocNo column or otherwise put it in a new column for forward use.

What should I do to achieve this?

  • 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-17T01:04:09+00:00Added an answer on June 17, 2026 at 1:04 am

    Try this

    UPDATE TableName
    SET LocNo =  CONVERT(INT, LocNo)
    

    If you want new column, add new column to table and then do update

    ALTER TABLE TableName
    ADD NewCol Int Null
    
    UPDATE TableName
    SET NewCol =  CONVERT(INT, LocNo)
    

    When Selecting and appending to varchar you can do

    SELECT CAST(LocNO As VARCHAR) + Name as NameAppended From TableName
    

    If you want 0's back in LocNo/newCol then

     SELECT right('00000' + CAST(LocNO As VARCHAR),0) + Name as NameAppended 
     From TableName
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Disclaimer: I am still learning SQL so I apologize if my question comes off
Disclaimer: I am still learning SQL so I apologize if my question comes off
The Disclaimer First of all, I know this question (or close variations) have been
Again disclaimer disclaimer still learning C# and OOP generally so I hope you'll be
Disclaimer: I don't have much SQL experience, and I don't know what version of
Disclaimer : My apologies for all the text below (for a single simple question),
First of all, a disclaimer: I have experience in other languages, but am still
Disclaimer: my SQL skills are basic, to say the least. Let's say I have
Disclaimer: i still suck at writing scripts please be gentle if this is a
Disclaimer: not sure this is WordPress related or not. I'm following a simple tutorial

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.