c# .net Adsense ADO.NET Linq Viruses/security asp.net MVC JQuery Angular-js Node-js SEO Java C++ SQL API Networking vb.net .Net Css JavaScript Generics c#.Net entity framework HTML Website host Website Construction Guide HTTP tutorial W3C tutorial Web Services JSON Psychology Ionic framework Angular ReactJS Python Computer Android
SQL

how to check table exists in SQL Server?

| | SQL

Best way to use an INFORMATION_SCHEMA view. These views are most standard across the plateform.


To check if a table exists use:


IF (EXISTS (SELECT * 
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = 'dbo'
AND TABLE_NAME = 'UserLogin'))
BEGIN
--Do Stuff
print 'hello'
END


Output:

hello