Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 Database Design and Application Architecture
 How to check first one record is in Table

Author  Topic 

Arunavally
Yak Posting Veteran

58 Posts

Posted - 2013-10-24 : 07:03:10
Hai,

I want to check if first record is in Table or not.

Kindly help me.
Thanks in Advance

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-10-24 : 08:31:17
Define what do you mean "First record". SQL doesnt have any concept of First or Last unless you specify order by means of ORDER BY clause.

If you attempt is to see if table has any rows use this


IF EXISTS (SELECT 1 FROM tableName)
...your code


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

Arunavally
Yak Posting Veteran

58 Posts

Posted - 2013-10-24 : 09:20:05
Thank you. I wan to chk table have any records or not?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-10-24 : 11:44:12
ok...then what i gave you would be enough.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

Arunavally
Yak Posting Veteran

58 Posts

Posted - 2013-10-25 : 00:33:25
I used
If exists (select 1 from table)

its wrk as my wish
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-10-25 : 03:00:05
cool

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -