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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:48:19+00:00 2026-06-09T18:48:19+00:00

I am inserting a 3 or 4 digit integer into a table that needs

  • 0

I am inserting a 3 or 4 digit integer into a table that needs the number to be 5 digits long. How do I add a 0 following the 4 digit number and a leading and following 0 to the 3 digit numbers when they transfer?

Edit- This is part of a trigger defined as follows:

create trigger Trig on T2 
after insert, update, delete 
as  
  -- So that @@rowcount does not get affected by trigger code     
set NoCount on  
  -- If c3 column participated in update (it most certainly did in insert)
if update(C3)
begin
  -- Insert or update triggered this operation
 if exists (select * from Inserted)
  begin
         insert into P1 (C1, C2, C3)
         select T1.C2, T1.C3, T2.C3 --INFORMATION THAT NEEDS TO BE TRANSFERRED 
         from T1
         -- Inserted is a pseudotable holding inserted/updated data
         inner join inserted T2
         on T1.C1 = T2.C2
         where T2.C4 <> 9 --DETERMINES IF RECORD NEEDS TO BE TRANSFERRED
  end
     else
     -- Separate insert for deleted records
     -- To simplify inserting additional info for deleted records only
     begin
         insert into P1 (C1, C2, C3)
         select T1.C2, T1.C3, T2.C3 --INFORMATION THAT NEEDS TO BE TRANSFERRED
         from T1
      -- deleted is a pseudotable holding deleted/updated data
         inner join deleted T2
         on T1.C1 = T2.C2
         where T2.C4 <> 9 --DETERMINES IF RECORD NEEDS TO BE TRANSFERRED
     end
 end 

Consider T2.C3 to be the pin number

  • 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-09T18:48:20+00:00Added an answer on June 9, 2026 at 6:48 pm

    Why do you need to store this? Just add it to the query or create a view that does so:

    SELECT RIGHT('0' + RTRIM(Number) + '0', 5) FROM dbo.TableName;
    

    You can of course perform the same operation on the values as you’re putting them into the table (either by modifying your insert statement or using a trigger if you have less control over DML).

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

Sidebar

Related Questions

When inserting a large number of rows into a single table hash cluster in
I am having trouble inserting values into my Account table that's in a SQL
When inserting a row into a table with an auto increment primary key column,
Before inserting data into table i need to check against duplicate records and report
While inserting rows into SQL Server CE in WP7 I'm getting a SQLCeException that
When inserting values into my table what do I edit here? Do I delete
Inserting multilingual data into a SQL 2008 database (nvarchar field) I notice that it
When inserting an object into a database with SQLAlchemy, all it's properties that correspond
After inserting new data into a table, I need to select some of the
I'm currently using the CURRENT_DATE when inserting into my table field for the Date.

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.