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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:48:05+00:00 2026-05-31T07:48:05+00:00

The problem is that the COLA has padded 0s What I am attempting to

  • 0

The problem is that the COLA has padded 0s

What I am attempting to do is verify COLB, COLC, COLD, COLE, COLF with COLA

Or have I gone about this the wrong way!

How do I get COLB, COLD to compare a Number (int) against a padded number substring ?


Example
that is correct

COLB    COLC    COLD    COLE    COLF               COLA

1        DD      5       1       0                     should = 01DD000510

not any of these

COLB   COLC   COLD  COLE   COLF    COLA

50     AA     230   2       0        0
50     AC     600   3       0
50     AG     740   2       0        50AE074020
50     AS     240   3       0        *0AS024030

 -- select that does not work statement.

 SELECT COLA ,
        COLB ,
        SUBSTRING(COLA, 1, 2) AS 'BLC_COLB' ,
        COLC ,
        SUBSTRING(COLA, 3, 2) AS 'BLC_COLC' ,
        COLD ,
        SUBSTRING(COLA, 5, 4) AS 'BLC_COLD' ,
        COLE ,
        SUBSTRING(COLA, 9, 1) AS 'BLC_COLE' ,
        COLF ,
        SUBSTRING(COLA, 10, 1) AS 'BLC_COLF'
 FROM   ATABLE
 WHERE  SUBSTRING(COLA, 1, 2) NOT LIKE COLB
        OR SUBSTRING(COLA, 3, 2) NOT LIKE COLC
        OR SUBSTRING(COLA, 5, 4) NOT LIKE COLD
        OR SUBSTRING(COLA, 9, 1) NOT LIKE COLE
        OR SUBSTRING(COLA, 10, 1) NOT LIKE COLF

--create table and data script

 CREATE TABLE [dbo].[ATABLE]
    (
      [ROWVERSION] [bigint] NULL ,
      [ROWDATE] [datetime] NULL ,
      [COLB] [int] NOT NULL ,
      [COLC] [nvarchar](2) NOT NULL ,
      [COLD] [int] NOT NULL ,
      [COLE] [nvarchar](1) NOT NULL ,
      [COLF] [int] NOT NULL ,
      [COLA] [nvarchar](14) NULL ,
      CONSTRAINT [CON1_0] PRIMARY KEY CLUSTERED
        ( [COLB] ASC, [COLC] ASC, [COLD] ASC, [COLE] ASC, [COLF] ASC )
        WITH ( PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF,
               IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON,
               ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 70 ) ON [PRIMARY]
    )
 ON [PRIMARY]

    GO
 SET NUMERIC_ROUNDABORT OFF
GO
 SET ANSI_PADDING, ANSI_WARNINGS, CONCAT_NULL_YIELDS_NULL, ARITHABORT, QUOTED_IDENTIFIER, ANSI_NULLS, NOCOUNT ON
GO
 SET DATEFORMAT YMD
GO
 SET XACT_ABORT ON
GO
 SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
GO
 BEGIN TRANSACTION

-- Add 5 rows to [dbo].[ATABLE] with non-unique comparison key
 SET ROWCOUNT 1
 INSERT INTO [dbo].[ATABLE]
        ( [COLB] ,
          [COLC] ,
          [COLD] ,
          [COLE] ,
          [COLF] ,
          [ROWVERSION] ,
          [ROWDATE] ,
          [COLA]
        )
 VALUES ( 1 ,
          N'DD' ,
          5 ,
          N'1' ,
          0 ,
          327520493236000002 ,
          '2011-07-04 10:21:33.227' ,
          N'01DD000510'
        )
 INSERT INTO [dbo].[ATABLE]
        ( [COLB] ,
          [COLC] ,
          [COLD] ,
          [COLE] ,
          [COLF] ,
          [ROWVERSION] ,
          [ROWDATE] ,
          [COLA]
        )
 VALUES ( 50 ,
          N'AA' ,
          230 ,
          N'2' ,
          0 ,
          327520514140000004 ,
          '2011-07-28 09:47:41.013' ,
          N'0'
        )
 INSERT INTO [dbo].[ATABLE]
        ( [COLB] ,
          [COLC] ,
          [COLD] ,
          [COLE] ,
          [COLF] ,
          [ROWVERSION] ,
          [ROWDATE] ,
          [COLA]
        )
 VALUES ( 50 ,
          N'AC' ,
          600 ,
          N'3' ,
          0 ,
          327520523360000007 ,
          '2011-07-28 09:48:09.577' ,
          N''
        )
 INSERT INTO [dbo].[ATABLE]
        ( [COLB] ,
          [COLC] ,
          [COLD] ,
          [COLE] ,
          [COLF] ,
          [ROWVERSION] ,
          [ROWDATE] ,
          [COLA]
        )
 VALUES ( 50 ,
          N'AG' ,
          740 ,
          N'2' ,
          0 ,
          327520543671000002 ,
          '2011-07-28 09:47:03.773' ,
          N'50AE074020'
        )
 INSERT INTO [dbo].[ATABLE]
        ( [COLB] ,
          [COLC] ,
          [COLD] ,
          [COLE] ,
          [COLF] ,
          [ROWVERSION] ,
          [ROWDATE] ,
          [COLA]
        )
 VALUES ( 50 ,
          N'AS' ,
          240 ,
          N'3' ,
          0 ,
          327520586618000007 ,
          '2011-07-28 09:48:08.453' ,
          N'*0AS024030'
        )
 SET ROWCOUNT 0
 COMMIT TRANSACTION
  • 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-05-31T07:48:07+00:00Added an answer on May 31, 2026 at 7:48 am

    Do this to select all rows that are “not verified”:

    SELECT  *
    FROM    ATABLE
    WHERE   RIGHT('0' + CAST(COLB AS VARCHAR), 2) +
            COLC +
            RIGHT('000' + CAST(COLD AS VARCHAR), 4) +
            COLE +
            CAST(COLF AS VARCHAR) <> COLA
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A problem that has frequently come up in my career is I have some
I have a problem that hopefully has a simple solution. I am trying to
The problem that I have is somehow very specific. I have to implement a
I have a strange problem that is only happening in a single location. I
I have a (big) problem that all of you that work with Webforms might
Ok I have this problem that I've never had before, it's really bugging me.
I'm facing a problem that seems to have no straighforward solution. I'm using java.util.Map
I recently have a problem that my java code works perfectly ok on my
I have a strange problem that I could not solve. When I try to
(I have a problem that I illustrated in this question but had no correct

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.