Hi,
I am trying to write the code using c#. Needed code to check whether the particulare data table from a database is exist or not. If not then create the table.
Please help me.
Hi,
I am trying to write the code using c#. Needed code to check whether the particulare data table from a database is exist or not. If not then create the table.
Please help me.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Len La SalaPosted Feb 9, 2009, 5:06 PM
For SQL Server try this, it works for me, I found it at http://sqlserver2000.databases.aspfaq.com/how-do-i-determine-if-a-table-exists-in-a-sql-server-database.html
IF EXISTS (SELECT 1
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE='BASE TABLE'
AND TABLE_NAME='tablename')
SELECT 'tablename exists.'
ELSE
SELECT 'tablename does not exist.'