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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. querry for displaying numbers and text seperate from table field using sql server

querry for displaying numbers and text seperate from table field using sql server

Scheduled Pinned Locked Moved Database
databasesql-serversysadminhelptutorial
5 Posts 5 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.
  • D Offline
    D Offline
    developerit
    wrote on last edited by
    #1

    hi iam using sql server 2000 in my table orders the fields are companyid int voucherdate smalldate description nvarchar(50) the problem is when i say select * from orders ; it is displaying orders like this 1 1/21/2010 1234orderscomleted 2 2/2/2010 67012requireurgent but i want to display in this format the number with paranthesis and the text 1 1/21/2010 (1234)orderscomleted 2 2/2/2010 (67012)requireurgent can you give example which helps me

    L _ M D 4 Replies Last reply
    0
    • D developerit

      hi iam using sql server 2000 in my table orders the fields are companyid int voucherdate smalldate description nvarchar(50) the problem is when i say select * from orders ; it is displaying orders like this 1 1/21/2010 1234orderscomleted 2 2/2/2010 67012requireurgent but i want to display in this format the number with paranthesis and the text 1 1/21/2010 (1234)orderscomleted 2 2/2/2010 (67012)requireurgent can you give example which helps me

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      You can do that in programming language like c# or vb.net but I think it is not possible using SQL.

      Jinal Desai

      1 Reply Last reply
      0
      • D developerit

        hi iam using sql server 2000 in my table orders the fields are companyid int voucherdate smalldate description nvarchar(50) the problem is when i say select * from orders ; it is displaying orders like this 1 1/21/2010 1234orderscomleted 2 2/2/2010 67012requireurgent but i want to display in this format the number with paranthesis and the text 1 1/21/2010 (1234)orderscomleted 2 2/2/2010 (67012)requireurgent can you give example which helps me

        _ Offline
        _ Offline
        _Damian S_
        wrote on last edited by
        #3

        By the look of your table design, the numbers and text are simply joined in the field "description". This means it will display exactly as the user has input it!! The easiest way would be for your users to input the data in the format you are after, or change your table design so that the number is stored in its own field, then you could simply select the number and append it into some parentheses! eg: select companyid, voucherdate, '(' + ordernumber + ')' as FormattedNumber, description from orders

        I don't have ADHD, I have ADOS... Attention Deficit oooh SHINY!! If you like cars, check out the Booger Mobile blog | If you feel generous - make a donation to Camp Quality!!

        1 Reply Last reply
        0
        • D developerit

          hi iam using sql server 2000 in my table orders the fields are companyid int voucherdate smalldate description nvarchar(50) the problem is when i say select * from orders ; it is displaying orders like this 1 1/21/2010 1234orderscomleted 2 2/2/2010 67012requireurgent but i want to display in this format the number with paranthesis and the text 1 1/21/2010 (1234)orderscomleted 2 2/2/2010 (67012)requireurgent can you give example which helps me

          M Offline
          M Offline
          Md Marufuzzaman
          wrote on last edited by
          #4

          If the data are showing; comes from single entry then i would like to suggest you to re-design you database table.

          Thanks Md. Marufuzzaman


          I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.

          1 Reply Last reply
          0
          • D developerit

            hi iam using sql server 2000 in my table orders the fields are companyid int voucherdate smalldate description nvarchar(50) the problem is when i say select * from orders ; it is displaying orders like this 1 1/21/2010 1234orderscomleted 2 2/2/2010 67012requireurgent but i want to display in this format the number with paranthesis and the text 1 1/21/2010 (1234)orderscomleted 2 2/2/2010 (67012)requireurgent can you give example which helps me

            D Offline
            D Offline
            David Skelly
            wrote on last edited by
            #5

            It's not the best database design in the world, so I agree with the others, your first approach should be to change the table design if you can. However, sometimes you don't have that option and the database design is out of your hands, so this link may help: http://www.kf7.co.uk/sql-server-function-get-numeric.aspx[^] You should be able to start from that and get something that works for you. It's not going to be fast, though.

            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