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. Dumb newbie like question

Dumb newbie like question

Scheduled Pinned Locked Moved Database
databasequestion
6 Posts 4 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.
  • B Offline
    B Offline
    Bangerman
    wrote on last edited by
    #1

    I have been using SQL for a while but I still cant get a definitive answer to this. Given a table with a dword column which of these is correct: INSERT INTO table (dvalue) VALUES ('0') or INSERT INTO table (dvalue) VALUES (0) I seem to have some examples for each and the DB engine I'm using seems to only allow the first.

    J 1 Reply Last reply
    0
    • B Bangerman

      I have been using SQL for a while but I still cant get a definitive answer to this. Given a table with a dword column which of these is correct: INSERT INTO table (dvalue) VALUES ('0') or INSERT INTO table (dvalue) VALUES (0) I seem to have some examples for each and the DB engine I'm using seems to only allow the first.

      J Offline
      J Offline
      Jeremy Oldham
      wrote on last edited by
      #2

      It depends on the datatype of the column. Assuming you a re using SQL Server, if the datatype of the column is float or int, then you would use the second example. For datatypes such as varchar, char, nvarchar and nchar, you would use your first example. Jeremy Jeremy Oldham

      B 1 Reply Last reply
      0
      • J Jeremy Oldham

        It depends on the datatype of the column. Assuming you a re using SQL Server, if the datatype of the column is float or int, then you would use the second example. For datatypes such as varchar, char, nvarchar and nchar, you would use your first example. Jeremy Jeremy Oldham

        B Offline
        B Offline
        Bangerman
        wrote on last edited by
        #3

        Thanks. Thats what I thought. Shame the implementation im using is busted then.

        D 1 Reply Last reply
        0
        • B Bangerman

          Thanks. Thats what I thought. Shame the implementation im using is busted then.

          D Offline
          D Offline
          David Salter
          wrote on last edited by
          #4

          Bangerman wrote: Shame the implementation im using is busted then. What DB are you using?

          B 1 Reply Last reply
          0
          • D David Salter

            Bangerman wrote: Shame the implementation im using is busted then. What DB are you using?

            B Offline
            B Offline
            Bangerman
            wrote on last edited by
            #5

            EDB V4.3 Its a real pain because im porting my app to use ODBC and I think I'm ging to end up having to have two versions of every SQL in my program.

            J 1 Reply Last reply
            0
            • B Bangerman

              EDB V4.3 Its a real pain because im porting my app to use ODBC and I think I'm ging to end up having to have two versions of every SQL in my program.

              J Offline
              J Offline
              Jon Hulatt
              wrote on last edited by
              #6

              No you're not. Implement a function like this (in pseudo code here) string DecideWhetherMyDBImplementationIsBrokenAndWrapANumberProperlyForIt ( DWORD n) { if (broken db) return "'" + string(n) + "'"; else return string(n); } and use that a lot.

              #include <beer.h>

              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