How to Create Table in a SQL Server Database if it does not exist

To check if the table exists in a SQL Server database and create it if it doesn't exist, use this code:

IF NOT EXISTS(
SELECT * FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = 'Schema_Name'


AND TABLE_NAME='Table_Name'
AND TABLE_TYPE ='BASE TABLE')
CREATE TABLE [Schema_Name].[Table_Name] (Column_Name int)

If the post helped you, please share it:
Pin It

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">