Solved

VS2010 - Data Access for a Project

Posted on 2014-04-07
6
381 Views
Last Modified: 2016-02-10
Hi and thanks,

I am very new to all this.

I would like to:

Determine what databases/tables are being accessed/updated within a project.

Apparently there is no documentation yet on the project(s).

I have not been assigned anything yet, but would like to be a little propared for the near future when I do.

I just am looking for some direction at this point???

Thanks
0
Comment
Question by:Amour22015
6 Comments
 
LVL 22

Assisted Solution

by:plusone3055
plusone3055 earned 70 total points
ID: 39984041
well the best way ot determine this is to look within the source code of the project/ application.

unless there is documentation on the application/project.  it could prove difficult.
of course you can always take guesses and then look at the databases and tables.

for instance
if you have an application that has 4 textboxews

first name
last name
DOB
phone number

you can always enter some data in and them run a search string query against the databases with the data you entered to determine that tables/columns  the data went into.  :)
0
 
LVL 6

Assisted Solution

by:Dulton
Dulton earned 180 total points
ID: 39984111
SQL Profiler may give you some insight in real-time. It isn't going to be a blueprint, but it can show you what is happening at that instant. (which means if you are curious, you can setup the profiler, execute the task/command you're questioning and then review the profiler trace to see what SQL did.

http://msdn.microsoft.com/en-us/library/ff650699.aspx

There are also some 3rd party tools which will document/diagram the dbs for you. I have no personal experience, but maybe others do! I won't promote any one over another since I've never used one.
0
 

Author Comment

by:Amour22015
ID: 39984395
Looks like I might have to do this the hard way and get all the table information within a database.


So far I have this:
USE Your Database Name
SELECT name FROM sys.tables
ORDER BY name

This works to bring up a list of Tables in a DB

BUT:
How can I get this to either get copied to word or printed???

Thanks
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 39985783
I suggest you look at something like Red Gate's SQL Doc.  This tool will document all your schema and code.
0
 
LVL 6

Accepted Solution

by:
Dulton earned 180 total points
ID: 39985811
If you're using Sql Server Management Studio, you can right click in the top-left of the output grid and either copy/paste into excel or word (I'd recommend excel for this) or rather choose "save as" and export the results as a tab delimited text file.

if you must have a text output, try this code here. if you toggle the parameter @OrderByScheama, you can change whether the schema begins the table name or is rather included in () at the end of the table name.

DECLARE @objId INT
DECLARE @t_name VARCHAR(260)    
DECLARE @c_name VARCHAR(128)
DECLARE @c_pos INT
DECLARE @d_type VARCHAR(128)
DECLARE @max_length INT
DECLARE @precision INT
DECLARE @nullable VARCHAR(8)
DECLARE @k_type VARCHAR(128)
DECLARE @OrderBySchema BIT = 1

 
DECLARE UserTbls CURSOR  FOR

        SELECT CASE  @OrderBySchema WHEN 1  THEN s.[name] + '.'  + t.[name]
                                                           ELSE t.[name] + ' ('  + s.[name] + ')'  END AS [t_name]
              ,c.[name] AS [c_name]
                  ,c.[column_id] AS [c_position]
                  ,t1.[name]
                  ,c.[max_length]
                  ,c.[precision]
                  ,CASE  WHEN c.[is_nullable] = 1 THEN  'NULL' ELSE 'NOT NULL' END AS  [Nullable]
                  ,k.[type_desc]
          FROM sys.[all_columns] AS c
INNER JOIN sys.[tables] AS t
                ON c.[object_id] = t.[object_id]
INNER JOIN sys.[schemas] AS s
            ON t.[schema_id] = s.[schema_id]
INNER JOIN sys.[types] as t1
                ON c.[user_type_id] = t1.[user_type_id]
LEFT JOIN [sys].[key_constraints] AS k
                ON t.[object_id] = k.[parent_object_id]
           AND c.[column_id] = k.[unique_index_id]
        WHERE t.[type] = 'U'            --user tables only
  ORDER BY  [t_name]
                  ,[c_position]

 
OPEN UserTbls
        FETCH NEXT  FROM UserTbls
                  INTO @t_name
                          ,@c_name
                          ,@c_pos
                          ,@d_type
                          ,@max_length
                          ,@precision
                          ,@nullable
                          ,@k_type

                WHILE @@FETCH_STATUS = 0
                        BEGIN
                        IF @c_pos  = 1
                                BEGIN
                                        PRINT ''
                                        PRINT @t_name  + Replicate(' ',10) + '(MaxLength,Precision)'
                                        PRINT Replicate('-',50)         
                                END                     

                                PRINT Replicate(' ',4) + @c_name  + ' ' 
                                                                           + @d_type +  '(' 
                                                                           + Cast(@max_length AS VARCHAR(10)) + ','
                                                                           + Cast(@precision AS VARCHAR(10)) + ') '
                                                                           + @nullable
                                                                           + Isnull(' ' + @k_type,'') 

                        FETCH NEXT  FROM UserTbls 
                                INTO @t_name
                                    ,@c_name
                                    ,@c_pos
                                    ,@d_type
                                    ,@max_length
                                    ,@precision
                                    ,@nullable
                                        ,@k_type

                        END

CLOSE UserTbls
DEALLOCATE userTbls

Open in new window

0
 

Author Closing Comment

by:Amour22015
ID: 39985876
Thanks to all...
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A couple of weeks ago, my client requested me to implement a SSIS package that allows them to download their files from a FTP server and archives them. Microsoft SSIS is the powerful tool which allows us to proceed multiple files at same time even w…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question