Showing posts with label ive. Show all posts
Showing posts with label ive. Show all posts

Tuesday, March 27, 2012

Determine last access of a database or table

Does anybody know of a way to determine the last date/time a table has been accessed (query/update)?

I've done enough research to know that this isn't easy. However, perhaps somebody has figured out a way through some of the stats that SQL Server keeps to determine the last access of a table.

I have recently been put on a team that had no DBA and has a number of databases out there. They would like to determine which databases are inactive and get rid of them. I am a developer and haven't had much SQL Server Administration experience.

Any info will help greatly!


Thanks!

Why not put a SQL Trace on each suspect database? That way you can soon determine the activity.

|||

I like that idea. Thanks for the suggestion!

Friday, March 9, 2012

Detach & Attach Database

I've just created ASPNETDB database with ASP.NET Security. Now, I want to send this db to orther computer.First, I detached this db, then when I used attach database in that computer, there is an error :

Error 602: Could not find row in sysindexes for database ID 8, object ID 1, indext ID 1. RUN DBCC CHECKTABLE on sysindexes.

Please help me .Thank.

I guess you're trying to attach a database from SQL2005/Express to a SQL2000 instance. Since most system objects have been changed in SQL2005, you can't use a SQL2005 database in SQL2000. What you can do is to transfer database objects/data/schema from SQL2005 to SQL2000.

|||How I do ? Could you guide me step by step ! Thank.|||You can open VS2005->new an Integration Service Project->add a Transfer SQL Server Objects Task

Friday, February 24, 2012

design questions

So, I don't have the most design experience... but thats about to change. Ive
got a DB that isn't in even 1st NF and has been in Production for some time.
There are hundreds of Stored Procs already and nobody is about to start
re-writing them. So, Im thinking I need to make use of Views. In this way,
existing SP's can stay the same, new SP's can be written against the new
table structures. Im sure Im not the first one to do this, so, any gotcha's?
Anything I need to have in my mind while I do the redesign so I don't spin my
wheels in the wrong direction and find this approach won't work?
--
TIA,
ChrisRChris,
> There are hundreds of Stored Procs already and nobody is about to start
> re-writing them. So, Im thinking I need to make use of Views. In this way,
> existing SP's can stay the same, new SP's can be written against the new
> table structures.
Obviously the best scenario would be a redesign to comply with 3rd NF
however it sounds like that is not going to happen. You already have an
abstraction layer to the underlying tables with stored procedures. Why do
you want to use views as well? I'm not saying that views should or should
not be used just trying to better understand your situation.
HTH
Jerry
"ChrisR" <ChrisR@.discussions.microsoft.com> wrote in message
news:6A3B81BB-2AE0-44BD-8BED-09D1F88E1398@.microsoft.com...
> So, I don't have the most design experience... but thats about to change.
> Ive
> got a DB that isn't in even 1st NF and has been in Production for some
> time.
> There are hundreds of Stored Procs already and nobody is about to start
> re-writing them. So, Im thinking I need to make use of Views. In this way,
> existing SP's can stay the same, new SP's can be written against the new
> table structures. Im sure Im not the first one to do this, so, any
> gotcha's?
> Anything I need to have in my mind while I do the redesign so I don't spin
> my
> wheels in the wrong direction and find this approach won't work?
> --
> TIA,
> ChrisR|||Depends what you mean by "not in 1NF". If you intend to declare new keys and
constraints then views alone won't stop the legacy code throwing constraint
violation errors. Also, not every view may be updateable.
Triggers on INSTEAD OF views might be an option but you might find that it's
easier to rewrite the procs rather than try to accommodate every one of them
in a trigger.
--
David Portas
SQL Server MVP
--
"ChrisR" wrote:
> So, I don't have the most design experience... but thats about to change. Ive
> got a DB that isn't in even 1st NF and has been in Production for some time.
> There are hundreds of Stored Procs already and nobody is about to start
> re-writing them. So, Im thinking I need to make use of Views. In this way,
> existing SP's can stay the same, new SP's can be written against the new
> table structures. Im sure Im not the first one to do this, so, any gotcha's?
> Anything I need to have in my mind while I do the redesign so I don't spin my
> wheels in the wrong direction and find this approach won't work?
> --
> TIA,
> ChrisR|||The use of Views would be this:
Lets say we have a table called "Client":
ClientID
LName
FName
Address
Address2
City
City2
State
State2
Child1
Child2
Child3
Child4
Child5
This doesn't look too far some of the tables we have. An option would be to
Rename Client to ClientTable with only 3 columns.
ClientID
LName
FName
Another table named ClientAddress. (More than 1 address can be entered here
if needed.)
ClientID
Address
City
State
And another table called ClientChild:(More than 1 child can be entered here
if needed.)
ClientID
Child
And finally, create a view named Client.
Create View Client
as
select * from ClientTable ct
inner join ClientAddress ca on ct.ClientId = ca.ClientId
inner join ClientChild cc on ct.ClientId = cc.ClientID
This is a tactic I've heard used by others, but never done it myself.
--
TIA,
ChrisR
"ChrisR" wrote:
> So, I don't have the most design experience... but thats about to change. Ive
> got a DB that isn't in even 1st NF and has been in Production for some time.
> There are hundreds of Stored Procs already and nobody is about to start
> re-writing them. So, Im thinking I need to make use of Views. In this way,
> existing SP's can stay the same, new SP's can be written against the new
> table structures. Im sure Im not the first one to do this, so, any gotcha's?
> Anything I need to have in my mind while I do the redesign so I don't spin my
> wheels in the wrong direction and find this approach won't work?
> --
> TIA,
> ChrisR|||Chris,
I am working on a major redesign at the moment. My shop also has lots of SPs
and tightly-coupled JSP code. My plan is to redesign the database from
scratch and then refactor the database and its attendant code bit by bit so
that in a year or so we will have completely re-engineered to database. In
other words,
1. Design a new, target schema.
2. Map the old schema to the new schema.
3. Develop a plan to convert "table clusters" from the old to the new schema.
4. Follow the plan.
For example, you may have a "company cluster" that consists of several
tables that handle company information. Convert this cluster from the old
schema to the new schema and rewrite your code base to utilize the new schema.
HTH,
Mike