Ms Sql If Exist

Ms Sql If Exist


  There are situations where you would like to perform some operations on table based on certain conditions

e.g. You would like to transfer some data from one table to another table but the condition is that should have less than 100 rows

Trick: use if statement instead of taking temporary variable

if ( (select count(*) from xyxTable with (nolock)) < 100)
begin

-- Do something

end

Tags:

Ms Sql If Existgodaddy hosting MS SQL server configurationThis page contains secure and none secure information Do you want to display the none secure itemsDo you want to display nonsecure itemsms sql slowms sql versionMS SQL server 2005 attach databse without ldf fileSql Server MirroringMS Sql Random selectms sql newid functionC# File ExistsAn unhandled exception of type systemstackoverflowexception occurred in mscorlibdll

Author

My name is Satalaj, but people call me Sat. Here is my homepage: . I live in Pune, PN and work as a Software Engineer. I'm former MVP in ASP.net year 2010.
Disclaimer: Views or opinion expressed here are my personal research and it has nothing to do with my employer. You are free to use the code, ideas/hints in your projects. However, you should not copy and paste my original content to other web sites. Feel free to copy or extend the code.
If you want to fight with me, this website is not for you.
 

I'm Satalaj.