Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. How to wirte this query

How to wirte this query

Scheduled Pinned Locked Moved Database
databasehelptutorial
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    varshavmane
    wrote on last edited by
    #1

    Hello All, I am using 2 databases. In one database I have table which has a column named PNumber and this column has data something like this : 7,189,413 7,196,205 7,202,331 7,217,254 In another database same column name is there but data is something like this: 7189413 7196205 7202331 7217254 I need to join these two column but I am not able to get the required data. Please help me... Thanks in advance....

    modified on Monday, August 11, 2008 7:18 AM

    A 1 Reply Last reply
    0
    • V varshavmane

      Hello All, I am using 2 databases. In one database I have table which has a column named PNumber and this column has data something like this : 7,189,413 7,196,205 7,202,331 7,217,254 In another database same column name is there but data is something like this: 7189413 7196205 7202331 7217254 I need to join these two column but I am not able to get the required data. Please help me... Thanks in advance....

      modified on Monday, August 11, 2008 7:18 AM

      A Offline
      A Offline
      Ashfield
      wrote on last edited by
      #2

      I am assuming that the data type is not a numeric one, otherwise your join would work, so try

      where replace(Pnumber,',','') = Pnumber

      This will strip the commas out.

      Bob Ashfield Consultants Ltd

      V 1 Reply Last reply
      0
      • A Ashfield

        I am assuming that the data type is not a numeric one, otherwise your join would work, so try

        where replace(Pnumber,',','') = Pnumber

        This will strip the commas out.

        Bob Ashfield Consultants Ltd

        V Offline
        V Offline
        varshavmane
        wrote on last edited by
        #3

        Thanks for the reply, but its not working. I want Expiry Date data but its not showing date. All the values in that column is Null but data is there in database...

        A 1 Reply Last reply
        0
        • V varshavmane

          Thanks for the reply, but its not working. I want Expiry Date data but its not showing date. All the values in that column is Null but data is there in database...

          A Offline
          A Offline
          Ashfield
          wrote on last edited by
          #4

          Ok, post the table definitions and your query and I'll try to help further.

          Bob Ashfield Consultants Ltd

          V 1 Reply Last reply
          0
          • A Ashfield

            Ok, post the table definitions and your query and I'll try to help further.

            Bob Ashfield Consultants Ltd

            V Offline
            V Offline
            varshavmane
            wrote on last edited by
            #5

            hey thanks a lot for the reply and help. Its working fine. I just used replace where I was doing join. Something like this:

            SELECT CONVERT(nvarchar(12), b.pexpiry_date, 101) as Expiry_Date FROM Table_A a
            left join Table_B b with(NoLock)
            on replace(a.pno,',','') = b.pnumber

            Thanks again... :)

            A B 2 Replies Last reply
            0
            • V varshavmane

              hey thanks a lot for the reply and help. Its working fine. I just used replace where I was doing join. Something like this:

              SELECT CONVERT(nvarchar(12), b.pexpiry_date, 101) as Expiry_Date FROM Table_A a
              left join Table_B b with(NoLock)
              on replace(a.pno,',','') = b.pnumber

              Thanks again... :)

              A Offline
              A Offline
              Ashfield
              wrote on last edited by
              #6

              Good, thats what I meant :)

              Bob Ashfield Consultants Ltd

              1 Reply Last reply
              0
              • V varshavmane

                hey thanks a lot for the reply and help. Its working fine. I just used replace where I was doing join. Something like this:

                SELECT CONVERT(nvarchar(12), b.pexpiry_date, 101) as Expiry_Date FROM Table_A a
                left join Table_B b with(NoLock)
                on replace(a.pno,',','') = b.pnumber

                Thanks again... :)

                B Offline
                B Offline
                Blue_Boy
                wrote on last edited by
                #7

                DECLARE @value AS VARCHAR(255) SET @value='78,567,9' SELECT REPLACE(@value,',','') I see you have already soultion but I hope you don't mind for my answer. Regards.


                I Love T-SQL "Don't torture yourself,let the life to do it for you."

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups