Documentation of a table of database - sql-server-2005

Can anyone suggest me the right way to begin with the documentation of the table of database I am working on. What actually I need to show to the evaluator?

Open SQL Server Management studio.
Then paste your table name, select the table name and then press ALT+F1. You will get all the details of the table as shown below in the image.

Related

Table missing in a database but query works

I have a table TBLT_GLDET in my SQL Server 2008 database. When I open a new query window and select the right database and execute following query
select *
from TBLT_GLDET;
the data appears. But in the tables list the table does not appear.
Also when I try to open the table for a Crystal Report using database expert in Visual Studio, it says the table is missing in the database.
What is the reason for this?
I did following things. I double checked whether it's the right database.
I refreshed the database.

there a way to drop 'sysmessages' table from one database?

unfortunately i create table call 'sysmessages' in SQL Server 2008. when i restore the DB to SQL Server 2012 i realize that i have two Tables call 'sysmessages'.
i don't want to change my table name because it using in the code.
can i remove only from specific database system table?
it is not a table, but a view
of course you cannot remove it, but you don't need to. It is in a different schema. You will not address it like select * from sys.sysmessages, you will address it like select * from dbo.sysmessages
"i don't want to change my table name because it is used in the code" - you can/should change the code as well :)
edit - no. 2. is not applicable in SQL 2012, however it is tested and working in SQL 2008R2
You cant drop system tables,your best bet is to change your code

generate create table from existing table

I have a few large tables in a oracle DB (lots of columns and data types) that I need to move to another oracle database (say from my DEV region to UAT region). Is there anyway I can get sql developer or sql plus to output a create table statement that is exactly the structure of the existing table?
thanks
If you want to get it through SQL statement then you can try the below query
SELECT dbms_metadata.get_ddl('TABLE', 'Your_Table_Name') FROM dual;
See DBMS_METADATA for more information.
You can generate the script using Toad software as well (In case you have Toad installed)
If you are making use of the SQL Developer you can right click the table that you want to generate a script for.
From there select Quick DDL and then click on Save To File. This will then generate the create table script to an external sql file. You can do this for multiple tables as well by selecting more than one table at a time.
Hope this helps!!
Another option is to create a database link between the two schemas and then do a
create table table_name AS SELECT * from table_name#original_server

SQL statement to find a table by its name

We have a lot of databases and a lot of tables within those databases. I'm searching for a specific one. I know the name of the table but it wouldn't be easy to search through every database manually. What SQL statement could I used to find the table by name?
Btw, we're using Microsoft SQL Server Management Studio. Maybe there's another way to search for tables by name within this program?
You said you did a search which should've led you to this article:
http://blog.sqlauthority.com/2008/04/29/sql-server-find-table-in-every-database-of-sql-server/
If not, follow that. Basically what he creates is a stored procedure which will search for every table name you specify in every database.
If you were to do this:
select * from sys.tables where name like '%tablename%'
You would need to change the database every single time and if you have a lot, well you see the problem.
Try this:
Select name from DBname.sys.tables where name like '%info'
Thought I would update with the solution I use now to find a table among many dBs. After some searching around I found this query:
/*Finds a table across multiple dBs and returns the dB(s) in which the table was found*/
SELECT DISTINCT DB_NAME(database_id)
FROM [sys].[dm_db_index_operational_stats](NULL,NULL,NULL,NULL)
WHERE OBJECT_NAME(object_id,database_id) = 'table name'
This query finds the dB which holds the table. Then, in Microsoft SQL Server Mgmt Studio, I go to Object Explorer Window, find the dB identified by the query, expand its contents, and click on the Tables folder. Then I use the Filter tool to find the table by name. It would be nice if the filter tool worked on the Databases folder but it does not. You must select the Tables folder before filtering.
This may not be the best solution, but it works for me.

show Create commands for table in SQL Management Studio (2008)

I've just started with SQL Management Studio and I am wondering if I can show create commands for already existing tables, I've been able to do that in Oracle SQL Developer.. I've tried to ask uncle google but maybe used just wrong search command.. Anyway.. could someone give me quick hint as I stuck with this for like 25 minutes?
Thanks
In Object Explorer, expand your server/database, expand Tables, right-click the table in question, and choose Script Table as > CREATE To > New Query Editor Window.
If you want to script multiple tables, you can turn on Object Explorer Details (F7 or from the View menu), highlight "Tables" on the left, then use Shift+ or Ctrl+ to select multiple tables in the right pane (just like you would select multiple files in Windows Explorer). Then you can do the same thing, right-click, Script Table as > ...
If you want to generate script for one table, right click a table and select "Script table as", you get all sorts of options including creating the create script of the table.
If you want to generate scripts for more than one table, you have option
to generate for many at once. Just follow the wizard instructions.