Showing posts with label t-sql. Show all posts
Showing posts with label t-sql. Show all posts

Wednesday, March 28, 2012

Relationship between t-Sql and "Set Theory"

I have always heard that much of t-sql is based on "set theory". I had Set theory in high school and I remember it as being simple Unions, Intersections, Differences of Sets. By a Set I mean a collection such as {2,5,7,8,9, ...) That could well described a single row in a table. By unioning several of these rows we could end up with a table.

But how does that relate to t-sql such as

select * from <table name> Where <condition 1> ?

Is it simply that the result returned by the query is a Set? (if so, a Set is simply being used as a synonym for a Collection. No set theory involved.)

TIA,

barkingdog

This is quite a large subject =;o)

Perhaps the best way is to point you to some reading, to get you started.
http://en.wikipedia.org/wiki/Relational_model

/Kenneth

Friday, March 9, 2012

Re-Index Script

I would like to re-index two tables (t1 and t2) if the logical scan
fragmentation is greater 80% on these tables.
Please help me create a t-sql script to create this task.
Thank You,Have a look at the samples in BooksOnLine under DBCC SHOWCONTIG.
Andrew J. Kelly SQL MVP
"Joe K." <Joe K.@.discussions.microsoft.com> wrote in message
news:E1AF96CD-2AC5-4BDB-AF79-43CAD668A773@.microsoft.com...
>I would like to re-index two tables (t1 and t2) if the logical scan
> fragmentation is greater 80% on these tables.
> Please help me create a t-sql script to create this task.
> Thank You,
>|||DBCC Showcontig will give you the information on how fragmented etc. is your
table.
You can use DBCC Reindex to Reindex your tables(TABLES WILL BE OFFLINE).
You can also use DBCC Defrag to defrag your tables(It's an online process).
Also, it'll grow your logfile like anything if your tables are huge. So,
Beware.