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. checking null values

checking null values

Scheduled Pinned Locked Moved Database
databasehelp
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.
  • M Offline
    M Offline
    minkinin
    wrote on last edited by
    #1

    Hi everyone. I am stucked,busy doing an access system for monitering the arrival,lunch and depature time of employees.I need a sql statement that checks if the timein and timeout column are null in the table. pls help. kind regards Minkinin.

    C R 2 Replies Last reply
    0
    • M minkinin

      Hi everyone. I am stucked,busy doing an access system for monitering the arrival,lunch and depature time of employees.I need a sql statement that checks if the timein and timeout column are null in the table. pls help. kind regards Minkinin.

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      SELECT * FROM SomeTable WHERE SomeColumn IS NULL


      Upcoming events: * Glasgow Geek Dinner (5th March) * Glasgow: Tell us what you want to see in 2007 My: Website | Blog | Photos

      M 1 Reply Last reply
      0
      • C Colin Angus Mackay

        SELECT * FROM SomeTable WHERE SomeColumn IS NULL


        Upcoming events: * Glasgow Geek Dinner (5th March) * Glasgow: Tell us what you want to see in 2007 My: Website | Blog | Photos

        M Offline
        M Offline
        minkinin
        wrote on last edited by
        #3

        let me clarify my question. I am busy with security access system for monitoring the arrival,lunch and depature time of employee,so when a user click an access card the system should check if that user has just arrived meaning that theres a record for arrival in the database,if not it should create it, so now I want a sql statement to check if theres null value in the table. my column names are: Date, Name, IN, OUT so if a user click an access card in the morning the record will be like this: DATE Name TimeIn OUT 07/02/07 Jomo 7:45 Null then when the user click the card during lunch, system willhave to check if the In and Out columns are null and insert that time on the null column, so when the user comes back from lunch it has to create a new record then the table will look like: Date Name Timein TimeOut 07/02/07 Jomo 7:45 12:00 o7/02/07 Jomo 1:00 Null so I need a sql statement which can always check if the time field is null so that it can insert time .

        P 1 Reply Last reply
        0
        • M minkinin

          let me clarify my question. I am busy with security access system for monitoring the arrival,lunch and depature time of employee,so when a user click an access card the system should check if that user has just arrived meaning that theres a record for arrival in the database,if not it should create it, so now I want a sql statement to check if theres null value in the table. my column names are: Date, Name, IN, OUT so if a user click an access card in the morning the record will be like this: DATE Name TimeIn OUT 07/02/07 Jomo 7:45 Null then when the user click the card during lunch, system willhave to check if the In and Out columns are null and insert that time on the null column, so when the user comes back from lunch it has to create a new record then the table will look like: Date Name Timein TimeOut 07/02/07 Jomo 7:45 12:00 o7/02/07 Jomo 1:00 Null so I need a sql statement which can always check if the time field is null so that it can insert time .

          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #4

          You could always do it like this in a stored procedure:

          IF EXISTS(SELECT * FROM Test
            WHERE [User] = @User AND [Out] IS NULL)
          BEGIN
          
              UPDATE Test
              SET [Out] = @TimeValue
              WHERE [User] = @User
              AND [Out] IS NULL
          
          END
          ELSE
          BEGIN
          
              INSERT INTO Test ([Date], [User], [In])
              VALUES (GETDATE(), @User, @TimeValue)
          
          END
          

          Swapping in your parameters obviously.

          the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
          Deja View - the feeling that you've seen this post before.

          M 1 Reply Last reply
          0
          • M minkinin

            Hi everyone. I am stucked,busy doing an access system for monitering the arrival,lunch and depature time of employees.I need a sql statement that checks if the timein and timeout column are null in the table. pls help. kind regards Minkinin.

            R Offline
            R Offline
            Rakesh Jha 0110
            wrote on last edited by
            #5

            try this if ur field is x in table xyz which u have to check its null or blank select x from xyz where isnull(x,'')<>'' this query check both null or blank in ur x colum give only filled records

            Rakesh Jha

            1 Reply Last reply
            0
            • P Pete OHanlon

              You could always do it like this in a stored procedure:

              IF EXISTS(SELECT * FROM Test
                WHERE [User] = @User AND [Out] IS NULL)
              BEGIN
              
                  UPDATE Test
                  SET [Out] = @TimeValue
                  WHERE [User] = @User
                  AND [Out] IS NULL
              
              END
              ELSE
              BEGIN
              
                  INSERT INTO Test ([Date], [User], [In])
                  VALUES (GETDATE(), @User, @TimeValue)
              
              END
              

              Swapping in your parameters obviously.

              the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
              Deja View - the feeling that you've seen this post before.

              M Offline
              M Offline
              minkinin
              wrote on last edited by
              #6

              Thank you very much,its working now. keep on the good srpirit.

              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