Tuesday, March 20, 2012

Save Table Definitions to Text File?

I don't know much about SQL Server yet and am going to start writing some
stored procedures. I thought the best way to reference the table names and
columns would be writing their definitions out to a text file like a report.
Any comments in this regard?
<%= Clinton GallagherIt looks like running exec sp_help <table-name> will work out but a nicely
formatted report of a database and its schema would be helpful to learn how
to do.
<%= Clinton Gallagher
"clintonG" < csgallagher@.REMOVETHISTEXTmetromilwaukee
.com> wrote in message
news:Oud%23G%23kYFHA.3572@.TK2MSFTNGP12.phx.gbl...
>I don't know much about SQL Server yet and am going to start writing some
>stored procedures. I thought the best way to reference the table names and
>columns would be writing their definitions out to a text file like a
>report.
> Any comments in this regard?
> <%= Clinton Gallagher
>|||If you want to build something on your own I suggest using the data from
SP_help and inserting that into a temporary table to use it further:
CREATE Table #TableDefs
(
Here goe the columns you need for sp_help
)
INSERT INTO #TableDefs
EXEC SP_HELP YourTableName
--<Further code to get though the Data to format it in some way>
Do you have Visio ? There are some nice build in feature for reengineering
your database. There are other programs out there which make reports of your
database.
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--
"clintonG" < csgallagher@.REMOVETHISTEXTmetromilwaukee
.com> schrieb im
Newsbeitrag news:ODc18SlYFHA.2796@.TK2MSFTNGP09.phx.gbl...
> It looks like running exec sp_help <table-name> will work out but a nicely
> formatted report of a database and its schema would be helpful to learn
> how to do.
>
> <%= Clinton Gallagher
>
> "clintonG" < csgallagher@.REMOVETHISTEXTmetromilwaukee
.com> wrote in message
> news:Oud%23G%23kYFHA.3572@.TK2MSFTNGP12.phx.gbl...
>|||Not bad ideas. Thanks for your comments Jens.
It takes time but using sp_help allowed me to copy and paste to a text file
and use tabs and so on to layout and organize a reference document that I
find useful to refer to while coding. The basics such as table name, column
name, type, length, and nullability is all I find I need.
I forgot all about Visio which I do have but as I recall Visio will generate
all or nothing results. We'll see... So many tools, so little time :-)
<%= Clinton Gallagher
"Jens Smeyer" <Jens@.Remove_this_For_Contacting.sqlserver2005.de> wrote in
message news:ezHvX4nYFHA.3040@.TK2MSFTNGP14.phx.gbl...
> If you want to build something on your own I suggest using the data from
> SP_help and inserting that into a temporary table to use it further:
> CREATE Table #TableDefs
> (
> Here goe the columns you need for sp_help
> )
> INSERT INTO #TableDefs
> EXEC SP_HELP YourTableName
> --<Further code to get though the Data to format it in some way>
> Do you have Visio ? There are some nice build in feature for reengineering
> your database. There are other programs out there which make reports of
> your database.
> --
> HTH, Jens Suessmeyer.
> --
> http://www.sqlserver2005.de
> --
> "clintonG" < csgallagher@.REMOVETHISTEXTmetromilwaukee
.com> schrieb im
> Newsbeitrag news:ODc18SlYFHA.2796@.TK2MSFTNGP09.phx.gbl...
>|||Hi
If you want to script the tables fully the easiest way it to use the
scripting options in Enterprise Manager or Query Analyser, but it sounds
like everything you may need could be already in the
INFORMATION_SCHEMA.COLUMNS view.
select * from INFORMATION_SCHEMA.COLUMNS
where TABLE_NAME = 'MyTable'
ORDER BY ORDINAL_POSITION
John
"clintonG" < csgallagher@.REMOVETHISTEXTmetromilwaukee
.com> wrote in message
news:Co%le.976$k43.342@.tornado.rdc-kc.rr.com...
> Not bad ideas. Thanks for your comments Jens.
> It takes time but using sp_help allowed me to copy and paste to a text
> file and use tabs and so on to layout and organize a reference document
> that I find useful to refer to while coding. The basics such as table
> name, column name, type, length, and nullability is all I find I need.
> I forgot all about Visio which I do have but as I recall Visio will
> generate all or nothing results. We'll see... So many tools, so little
> time :-)
> <%= Clinton Gallagher
> "Jens Smeyer" <Jens@.Remove_this_For_Contacting.sqlserver2005.de> wrote
> in message news:ezHvX4nYFHA.3040@.TK2MSFTNGP14.phx.gbl...
>

No comments:

Post a Comment