devxlogo

Using T-SQL to Check Whether a Table Exists

Using T-SQL to Check Whether a Table Exists

Assume that an application creates a new table every month. The table name can be coined using some pattern, like sales0501, sales0502,, etc.

To identify whether a particular table exists in a database, the following query can be used in the application:

"select name from sysobjects where xtype='u' and name = @tblName"

@tblName is the table name to be searched in the database and @tblName is the input parameter for the query.

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist