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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T08:44:07+00:00 2026-06-16T08:44:07+00:00

I have four columns in a table Id Int Name varchar(2) Address varchar (4)

  • 0

I have four columns in a table

Id Int
Name varchar(2)
Address varchar (4)
Active bit

and the source table with the same columns but have the varchar data type.

Id varchar(100)
Name varchar(100)
Address varchar (100)
Active varchar(100)

I have to transfer data from source table to destination table, but while transfering I need to check if the row I have has the correct data type for the destination. If not I need to transfer that complete row to some error table. ex.:

ID Name Address Active
1  A     A       1
C  B     B       0
3  AAA   C       1 
4  D     D       0
5  K     K       102

if above represnt the source table and only rows 1 and 4 are eligible to tranfer to the destination table other rows will be moved to error table (may be with valid description, if possible)

  • 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-16T08:44:08+00:00Added an answer on June 16, 2026 at 8:44 am

    Something like this

    insert into destination
    select * from source 
    where (isnumeric(ID)=1 
            and 
            (ID not like '%[^0-9]%')
            and 
            RIGHT('00000000000'+ID,10) <= '2147483647'
          ) 
          and
          len(name)<=2
          and
          len(Address)<=4
          and
          active in ('0','1')
    

    So to insert into ERRORS table use NOT in WHERE

    insert into ERRORS
    select * from source 
    where 
       NOT
         (
          (isnumeric(ID)=1 
            and 
            (ID not like '%[^0-9]%')
            and 
            RIGHT('00000000000'+ID,10) <= '2147483647'
          ) 
          and
          len(name)<=2
          and
          len(Address)<=4
          and
          active in ('0','1')
        )
    

    SQLFiddle demo

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

Sidebar

Related Questions

I have a table with four columns, say P_Key(int), Ref_Key(int), Key(String), Value(Integer). I want
In my table accounts I have four columns like user, pass, column1, column2 I
I have a table with four Columns: Col1, Col2, Col3, and Col4. Col1, Col2,
I have a fairly static (InnoDB) table T with four columns: A , B
I have a data frame of daily data: df with four columns: Date, A,
I have a table with four columns, where col1 & col2 contain similar values
I have a table for image gallery with four columns like: foid | uid
I have a table with data : id one two three four five six
I have a database table has four columns called Courses(CourseID,CourseName,CreditHours,LabSession) , and I wanna
I have four columns in a table: date entered, time entered, date completed, time

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.