I am writing a Stored procedure in SQL Server 2008. I need to check if a table exists in the database. If it doesn\'t then I need to create it.
How do I do this?
EDITED
You can look into sys.tables for checking existence desired table:
IF NOT EXISTS (SELECT * FROM sys.tables WHERE name = N'YourTable' AND type = 'U') BEGIN CREATE TABLE [SchemaName].[YourTable]( .... .... .... ) END