You are hereSQL SERVER - 2005 - List Tables in Database

SQL SERVER - 2005 - List Tables in Database


By edwin - Posted on 23 March 2009

This is very simple but effective script. It list all the table names.

  1. USE DatabaseName;
  2. GO
  3. SELECT SCHEMA_NAME(schema_id) AS SchemaName,name AS TableName
  4. FROM sys.TABLES
  5. ORDER BY SchemaName, TableName;
  6. GO

Tags

getting Error

Msg 195, Level 15, State 10, Line 1
'SCHEMA_NAME' is not a recognized function name.

Apparently, this happens when you have two versions of SQL Server installed on the same computer. Go to a command prompt and re-register sqldmo.dll.

Regsvr32 Sqldmo.dll

You should get a prompt back that states DLLRegisterServer in SQLDMO.dll succeeded.
Reboot your server and try again.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <img> <span>
  • Lines and paragraphs break automatically.
  • Pairs of<blockquote> tags will be styled as a block that indicates a quotation.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. The supported tag styles are: <foo>, [foo].
  • Images can be added to this post.

More information about formatting options