SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how do I check if SQL server row is empty

    hello,
    how do i check with a select statement to see if a certain record does not exisit in an SQL server database ?

    thanks

  2. #2
    SitePoint Guru MikeBigg's Avatar
    Join Date
    Jun 2004
    Location
    Reading, UK
    Posts
    970
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can use count(*) to report the number of rows in a table:

    select count(*) from MyTable

    or for a table with a given where clause:

    select count(*) from MyTable where Id=17

    and you can rename the count(*) column in the query to make it easier to reference in associated code (if you are using any):

    select count(*) as TheCount from MyTable

    Mike

  3. #3
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i dont know why i never thought of the count property

    thanks Mike

  4. #4
    SitePoint Guru MikeBigg's Avatar
    Join Date
    Jun 2004
    Location
    Reading, UK
    Posts
    970
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My pleasure.

    Mike


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •