how to get details of each table of a database in sql server

  • Hi guys , i have a new problem . I have got a old database ,and my senior has asked me to study the database and get to know about each table of the database.The database is having 180 tables.If there any method by which i can get the information about each table . The database diagrams gives the columns names and the relations ship . Can i get the information in the following format

    Table

    ---------

    ColumnName Datatype AllowNull Constraints Relationships

    --------------------------------------------------------

    And also i should be able to take printout

    Note:guys i am very new to sql server

  • Hi,

    Sorry for the delay in getting a response.

    You could have a look at the code attached, I've put it together really quickly so it's a little messy but should do what you want it to.

    One thing though, if a column has both a default and a foreign key then you would get 2 records back, I imagine you probably want only one, so you could just copy the join and have one join for defaults and one for constraints. Any problems with that bit then let me know and I will find a bit of time to help you out.

    Hope this helps, i'm sure there is probably a better way of doing it, but this just popped into my head, and it appears to be working. The other way you can get some info is by executing sp_help again your table, like EXEC sp_help 'table_1' This will give you all the information as well, but the format may be a bit much.

    Good luck.

  • thanks it was usefull.Is there any techinuque in server whereby can take the print out of a query result or copy the query result in a text file

  • Hi,

    You can save a query result to a text file by either clicking the 'results to file' button at the top of the SSMS and then running the query.

  • thank you very much . I hope we can keep in touch in future also

  • yeah no problem, if you need any more info or have any questions then just post them up on the forum or private message me.

    Regards,

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply