This is not needed in general development times. But, very rare cases only we have to get these kind of requirements and use these rarely used commands. I have a requirement where I need to know the list of tables in a database and do something. So, below is the simple query which is used to list or display the tables in a database.
select [name] from dbo.sysobjects where OBJECTPROPERTY(id, N'IsUserTable') = 1
"sysobjects" is the system table which holds all objects in a database. By using where clause "IsUserTable" returns true if it is a table and filtering the results.
Hope this helps.
No comments:
Post a Comment