How do I delete rows that are older than 180 days if the table does not
contain a column of timestamp? The following statement works fine if
parameter startdate is known:
DELETE From MyTable Where DATEDIFF (day, startdate, GETDATE()) > 180
Thanks in advance.
-tcYou don't. Unless you can join with another table that has a datetime
column. (Every table 'should' have such a column: RecordCreated datetime)
And 'timestamp' as the timestamp datatype has nothing to do with TIME.
Arnie Rowland
"To be successful, your heart must accompany your knowledge."
"tcw" <tcwangs@.msn.com> wrote in message
news:%23yZt9I4pGHA.4912@.TK2MSFTNGP05.phx.gbl...
> How do I delete rows that are older than 180 days if the table does not
> contain a column of timestamp? The following statement works fine if
> parameter startdate is known:
> DELETE From MyTable Where DATEDIFF (day, startdate, GETDATE()) > 180
> Thanks in advance.
> -tc
>|||SQL Server does not track this information, so you're going to have to add a
column like:
ALTER TABLE MyTable ADD CreatedDate SMALLDATETIME NOT NULL DEFAULT
CURRENT_TIMESTAMP;
Of course, you won't be able to take advantage of the values for this
specifc task until 6 more months have passed.
A
"tcw" <tcwangs@.msn.com> wrote in message
news:%23yZt9I4pGHA.4912@.TK2MSFTNGP05.phx.gbl...
> How do I delete rows that are older than 180 days if the table does not
> contain a column of timestamp? The following statement works fine if
> parameter startdate is known:
> DELETE From MyTable Where DATEDIFF (day, startdate, GETDATE()) > 180
> Thanks in advance.
> -tc
>|||> (Every table 'should' have such a column: RecordCreated datetime)
Whoa, that's a pretty broad generalization. Such a column is useful, but in
most applications it isn't necessary on every single table.
A|||Very True, but I prefer to drive home the point for the generalization, and
then once the idea has taken hold, start dealing with the exceptions. And of
course, not needed at all in some databases.
But for general business data ...
Arnie Rowland
"To be successful, your heart must accompany your knowledge."
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in mess
age
news:epyLdq4pGHA.4812@.TK2MSFTNGP04.phx.gbl...
> Whoa, that's a pretty broad generalization. Such a column is useful, but
> in most applications it isn't necessary on every single table.
> A
>|||It would be better to drive home the fact that each row should take up as
little space as possible and then deal with the exceptions. That way you
encourage efficiency.
Best regards
Mark Baldwin
"Arnie Rowland" <arnie@.1568.com> wrote in message
news:eiBkZz4pGHA.4912@.TK2MSFTNGP05.phx.gbl...
> Very True, but I prefer to drive home the point for the generalization,
> and then once the idea has taken hold, start dealing with the exceptions.
> And of course, not needed at all in some databases.
> But for general business data ...
> --
> Arnie Rowland
> "To be successful, your heart must accompany your knowledge."
>
> "Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in
> message news:epyLdq4pGHA.4812@.TK2MSFTNGP04.phx.gbl...
>|||I'm less concerned with saving 4 or 8 bytes than with having a 'robust' data
system -I keep hearing storage is inexpensive. Perhaps it's just the segment
of large corporation and government agencies that I work with, but for the
last several years, all projects I've worked with have either required or
benefited from having not only a date column (entered/changed) -but also a
column capturing 'who' was responsible. And updates/deletes from selected
tables may be shadowed to an archive table/server. I tend to work with
VLDB's that must meet requirements set out by Aegis (law enforcement),
SarBox (financial), and/or HIPPA (medical).
Personally, I think that business systems 'should' have date and person
columns on almost every table. They solve so many of the 'problems' that
come up over a project's lifecycle. -Such as the one posted by the OP.
Arnie Rowland
"To be successful, your heart must accompany your knowledge."
"Mark" <swozz_@.hotmail.com> wrote in message
news:OT$O7e$pGHA.5064@.TK2MSFTNGP05.phx.gbl...
> It would be better to drive home the fact that each row should take up as
> little space as possible and then deal with the exceptions. That way you
> encourage efficiency.
> --
> Best regards
> Mark Baldwin
>
> "Arnie Rowland" <arnie@.1568.com> wrote in message
> news:eiBkZz4pGHA.4912@.TK2MSFTNGP05.phx.gbl...
>|||> benefited from having not only a date column (entered/changed) -but also
> a column capturing 'who' was responsible.
That kind of data, imho, belongs in a separate auditing table.
Otherwise, you are forced to either have really wide tables or only track
the LAST person who changed it.
> Personally, I think that business systems 'should' have date and person
> columns on almost every table.
I think for higher level entities that's not a bad idea. For complex OLTP
systems with hundreds of tables, you're going to drown yourself in
information overload.
A|||Thank you very much, guys. I think I will add a timestamp column to my table
next time.
-tc
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in mess
age
news:eo6cup4pGHA.148@.TK2MSFTNGP04.phx.gbl...
> SQL Server does not track this information, so you're going to have to add
> a column like:
> ALTER TABLE MyTable ADD CreatedDate SMALLDATETIME NOT NULL DEFAULT
> CURRENT_TIMESTAMP;
> Of course, you won't be able to take advantage of the values for this
> specifc task until 6 more months have passed.
> A
>
> "tcw" <tcwangs@.msn.com> wrote in message
> news:%23yZt9I4pGHA.4912@.TK2MSFTNGP05.phx.gbl...
>|||"tcw" <tcwangs@.msn.com> wrote in message
news:egpsl9GqGHA.4932@.TK2MSFTNGP05.phx.gbl...
> Thank you very much, guys. I think I will add a timestamp column to my
table
> next time.
Note: To be perfectly clear, you wanta datetime (or smalldatetime) column.
Timestamp is a separate datatype which actually doesn't map to date or time.
> -tc
> "Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in
message
> news:eo6cup4pGHA.148@.TK2MSFTNGP04.phx.gbl...
add[vbcol=seagreen]
>
Showing posts with label older. Show all posts
Showing posts with label older. Show all posts
Monday, March 26, 2012
How to get the record created date?
How do I delete rows that are older than 180 days if the table does not
contain a column of timestamp? The following statement works fine if
parameter startdate is known:
DELETE From MyTable Where DATEDIFF (day, startdate, GETDATE()) > 180
Thanks in advance.
-tcYou don't. Unless you can join with another table that has a datetime
column. (Every table 'should' have such a column: RecordCreated datetime)
And 'timestamp' as the timestamp datatype has nothing to do with TIME.
--
Arnie Rowland
"To be successful, your heart must accompany your knowledge."
"tcw" <tcwangs@.msn.com> wrote in message
news:%23yZt9I4pGHA.4912@.TK2MSFTNGP05.phx.gbl...
> How do I delete rows that are older than 180 days if the table does not
> contain a column of timestamp? The following statement works fine if
> parameter startdate is known:
> DELETE From MyTable Where DATEDIFF (day, startdate, GETDATE()) > 180
> Thanks in advance.
> -tc
>|||SQL Server does not track this information, so you're going to have to add a
column like:
ALTER TABLE MyTable ADD CreatedDate SMALLDATETIME NOT NULL DEFAULT
CURRENT_TIMESTAMP;
Of course, you won't be able to take advantage of the values for this
specifc task until 6 more months have passed.
A
"tcw" <tcwangs@.msn.com> wrote in message
news:%23yZt9I4pGHA.4912@.TK2MSFTNGP05.phx.gbl...
> How do I delete rows that are older than 180 days if the table does not
> contain a column of timestamp? The following statement works fine if
> parameter startdate is known:
> DELETE From MyTable Where DATEDIFF (day, startdate, GETDATE()) > 180
> Thanks in advance.
> -tc
>|||> (Every table 'should' have such a column: RecordCreated datetime)
Whoa, that's a pretty broad generalization. Such a column is useful, but in
most applications it isn't necessary on every single table.
A|||Very True, but I prefer to drive home the point for the generalization, and
then once the idea has taken hold, start dealing with the exceptions. And of
course, not needed at all in some databases.
But for general business data ...
--
Arnie Rowland
"To be successful, your heart must accompany your knowledge."
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:epyLdq4pGHA.4812@.TK2MSFTNGP04.phx.gbl...
>> (Every table 'should' have such a column: RecordCreated datetime)
> Whoa, that's a pretty broad generalization. Such a column is useful, but
> in most applications it isn't necessary on every single table.
> A
>|||It would be better to drive home the fact that each row should take up as
little space as possible and then deal with the exceptions. That way you
encourage efficiency.
--
Best regards
Mark Baldwin
"Arnie Rowland" <arnie@.1568.com> wrote in message
news:eiBkZz4pGHA.4912@.TK2MSFTNGP05.phx.gbl...
> Very True, but I prefer to drive home the point for the generalization,
> and then once the idea has taken hold, start dealing with the exceptions.
> And of course, not needed at all in some databases.
> But for general business data ...
> --
> Arnie Rowland
> "To be successful, your heart must accompany your knowledge."
>
> "Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in
> message news:epyLdq4pGHA.4812@.TK2MSFTNGP04.phx.gbl...
>> (Every table 'should' have such a column: RecordCreated datetime)
>> Whoa, that's a pretty broad generalization. Such a column is useful, but
>> in most applications it isn't necessary on every single table.
>> A
>|||I'm less concerned with saving 4 or 8 bytes than with having a 'robust' data
system -I keep hearing storage is inexpensive. Perhaps it's just the segment
of large corporation and government agencies that I work with, but for the
last several years, all projects I've worked with have either required or
benefited from having not only a date column (entered/changed) -but also a
column capturing 'who' was responsible. And updates/deletes from selected
tables may be shadowed to an archive table/server. I tend to work with
VLDB's that must meet requirements set out by Aegis (law enforcement),
SarBox (financial), and/or HIPPA (medical).
Personally, I think that business systems 'should' have date and person
columns on almost every table. They solve so many of the 'problems' that
come up over a project's lifecycle. -Such as the one posted by the OP.
--
Arnie Rowland
"To be successful, your heart must accompany your knowledge."
"Mark" <swozz_@.hotmail.com> wrote in message
news:OT$O7e$pGHA.5064@.TK2MSFTNGP05.phx.gbl...
> It would be better to drive home the fact that each row should take up as
> little space as possible and then deal with the exceptions. That way you
> encourage efficiency.
> --
> Best regards
> Mark Baldwin
>
> "Arnie Rowland" <arnie@.1568.com> wrote in message
> news:eiBkZz4pGHA.4912@.TK2MSFTNGP05.phx.gbl...
>> Very True, but I prefer to drive home the point for the generalization,
>> and then once the idea has taken hold, start dealing with the exceptions.
>> And of course, not needed at all in some databases.
>> But for general business data ...
>> --
>> Arnie Rowland
>> "To be successful, your heart must accompany your knowledge."
>>
>> "Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in
>> message news:epyLdq4pGHA.4812@.TK2MSFTNGP04.phx.gbl...
>> (Every table 'should' have such a column: RecordCreated datetime)
>> Whoa, that's a pretty broad generalization. Such a column is useful,
>> but in most applications it isn't necessary on every single table.
>> A
>>
>|||> benefited from having not only a date column (entered/changed) -but also
> a column capturing 'who' was responsible.
That kind of data, imho, belongs in a separate auditing table.
Otherwise, you are forced to either have really wide tables or only track
the LAST person who changed it.
> Personally, I think that business systems 'should' have date and person
> columns on almost every table.
I think for higher level entities that's not a bad idea. For complex OLTP
systems with hundreds of tables, you're going to drown yourself in
information overload.
A|||Thank you very much, guys. I think I will add a timestamp column to my table
next time.
-tc
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:eo6cup4pGHA.148@.TK2MSFTNGP04.phx.gbl...
> SQL Server does not track this information, so you're going to have to add
> a column like:
> ALTER TABLE MyTable ADD CreatedDate SMALLDATETIME NOT NULL DEFAULT
> CURRENT_TIMESTAMP;
> Of course, you won't be able to take advantage of the values for this
> specifc task until 6 more months have passed.
> A
>
> "tcw" <tcwangs@.msn.com> wrote in message
> news:%23yZt9I4pGHA.4912@.TK2MSFTNGP05.phx.gbl...
>> How do I delete rows that are older than 180 days if the table does not
>> contain a column of timestamp? The following statement works fine if
>> parameter startdate is known:
>> DELETE From MyTable Where DATEDIFF (day, startdate, GETDATE()) > 180
>> Thanks in advance.
>> -tc
>|||"tcw" <tcwangs@.msn.com> wrote in message
news:egpsl9GqGHA.4932@.TK2MSFTNGP05.phx.gbl...
> Thank you very much, guys. I think I will add a timestamp column to my
table
> next time.
Note: To be perfectly clear, you wanta datetime (or smalldatetime) column.
Timestamp is a separate datatype which actually doesn't map to date or time.
> -tc
> "Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in
message
> news:eo6cup4pGHA.148@.TK2MSFTNGP04.phx.gbl...
> > SQL Server does not track this information, so you're going to have to
add
> > a column like:
> >
> > ALTER TABLE MyTable ADD CreatedDate SMALLDATETIME NOT NULL DEFAULT
> > CURRENT_TIMESTAMP;
> >
> > Of course, you won't be able to take advantage of the values for this
> > specifc task until 6 more months have passed.
> >
> > A
> >
> >
> > "tcw" <tcwangs@.msn.com> wrote in message
> > news:%23yZt9I4pGHA.4912@.TK2MSFTNGP05.phx.gbl...
> >> How do I delete rows that are older than 180 days if the table does not
> >> contain a column of timestamp? The following statement works fine if
> >> parameter startdate is known:
> >>
> >> DELETE From MyTable Where DATEDIFF (day, startdate, GETDATE()) > 180
> >>
> >> Thanks in advance.
> >>
> >> -tc
> >>
> >
> >
>sql
contain a column of timestamp? The following statement works fine if
parameter startdate is known:
DELETE From MyTable Where DATEDIFF (day, startdate, GETDATE()) > 180
Thanks in advance.
-tcYou don't. Unless you can join with another table that has a datetime
column. (Every table 'should' have such a column: RecordCreated datetime)
And 'timestamp' as the timestamp datatype has nothing to do with TIME.
--
Arnie Rowland
"To be successful, your heart must accompany your knowledge."
"tcw" <tcwangs@.msn.com> wrote in message
news:%23yZt9I4pGHA.4912@.TK2MSFTNGP05.phx.gbl...
> How do I delete rows that are older than 180 days if the table does not
> contain a column of timestamp? The following statement works fine if
> parameter startdate is known:
> DELETE From MyTable Where DATEDIFF (day, startdate, GETDATE()) > 180
> Thanks in advance.
> -tc
>|||SQL Server does not track this information, so you're going to have to add a
column like:
ALTER TABLE MyTable ADD CreatedDate SMALLDATETIME NOT NULL DEFAULT
CURRENT_TIMESTAMP;
Of course, you won't be able to take advantage of the values for this
specifc task until 6 more months have passed.
A
"tcw" <tcwangs@.msn.com> wrote in message
news:%23yZt9I4pGHA.4912@.TK2MSFTNGP05.phx.gbl...
> How do I delete rows that are older than 180 days if the table does not
> contain a column of timestamp? The following statement works fine if
> parameter startdate is known:
> DELETE From MyTable Where DATEDIFF (day, startdate, GETDATE()) > 180
> Thanks in advance.
> -tc
>|||> (Every table 'should' have such a column: RecordCreated datetime)
Whoa, that's a pretty broad generalization. Such a column is useful, but in
most applications it isn't necessary on every single table.
A|||Very True, but I prefer to drive home the point for the generalization, and
then once the idea has taken hold, start dealing with the exceptions. And of
course, not needed at all in some databases.
But for general business data ...
--
Arnie Rowland
"To be successful, your heart must accompany your knowledge."
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:epyLdq4pGHA.4812@.TK2MSFTNGP04.phx.gbl...
>> (Every table 'should' have such a column: RecordCreated datetime)
> Whoa, that's a pretty broad generalization. Such a column is useful, but
> in most applications it isn't necessary on every single table.
> A
>|||It would be better to drive home the fact that each row should take up as
little space as possible and then deal with the exceptions. That way you
encourage efficiency.
--
Best regards
Mark Baldwin
"Arnie Rowland" <arnie@.1568.com> wrote in message
news:eiBkZz4pGHA.4912@.TK2MSFTNGP05.phx.gbl...
> Very True, but I prefer to drive home the point for the generalization,
> and then once the idea has taken hold, start dealing with the exceptions.
> And of course, not needed at all in some databases.
> But for general business data ...
> --
> Arnie Rowland
> "To be successful, your heart must accompany your knowledge."
>
> "Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in
> message news:epyLdq4pGHA.4812@.TK2MSFTNGP04.phx.gbl...
>> (Every table 'should' have such a column: RecordCreated datetime)
>> Whoa, that's a pretty broad generalization. Such a column is useful, but
>> in most applications it isn't necessary on every single table.
>> A
>|||I'm less concerned with saving 4 or 8 bytes than with having a 'robust' data
system -I keep hearing storage is inexpensive. Perhaps it's just the segment
of large corporation and government agencies that I work with, but for the
last several years, all projects I've worked with have either required or
benefited from having not only a date column (entered/changed) -but also a
column capturing 'who' was responsible. And updates/deletes from selected
tables may be shadowed to an archive table/server. I tend to work with
VLDB's that must meet requirements set out by Aegis (law enforcement),
SarBox (financial), and/or HIPPA (medical).
Personally, I think that business systems 'should' have date and person
columns on almost every table. They solve so many of the 'problems' that
come up over a project's lifecycle. -Such as the one posted by the OP.
--
Arnie Rowland
"To be successful, your heart must accompany your knowledge."
"Mark" <swozz_@.hotmail.com> wrote in message
news:OT$O7e$pGHA.5064@.TK2MSFTNGP05.phx.gbl...
> It would be better to drive home the fact that each row should take up as
> little space as possible and then deal with the exceptions. That way you
> encourage efficiency.
> --
> Best regards
> Mark Baldwin
>
> "Arnie Rowland" <arnie@.1568.com> wrote in message
> news:eiBkZz4pGHA.4912@.TK2MSFTNGP05.phx.gbl...
>> Very True, but I prefer to drive home the point for the generalization,
>> and then once the idea has taken hold, start dealing with the exceptions.
>> And of course, not needed at all in some databases.
>> But for general business data ...
>> --
>> Arnie Rowland
>> "To be successful, your heart must accompany your knowledge."
>>
>> "Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in
>> message news:epyLdq4pGHA.4812@.TK2MSFTNGP04.phx.gbl...
>> (Every table 'should' have such a column: RecordCreated datetime)
>> Whoa, that's a pretty broad generalization. Such a column is useful,
>> but in most applications it isn't necessary on every single table.
>> A
>>
>|||> benefited from having not only a date column (entered/changed) -but also
> a column capturing 'who' was responsible.
That kind of data, imho, belongs in a separate auditing table.
Otherwise, you are forced to either have really wide tables or only track
the LAST person who changed it.
> Personally, I think that business systems 'should' have date and person
> columns on almost every table.
I think for higher level entities that's not a bad idea. For complex OLTP
systems with hundreds of tables, you're going to drown yourself in
information overload.
A|||Thank you very much, guys. I think I will add a timestamp column to my table
next time.
-tc
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:eo6cup4pGHA.148@.TK2MSFTNGP04.phx.gbl...
> SQL Server does not track this information, so you're going to have to add
> a column like:
> ALTER TABLE MyTable ADD CreatedDate SMALLDATETIME NOT NULL DEFAULT
> CURRENT_TIMESTAMP;
> Of course, you won't be able to take advantage of the values for this
> specifc task until 6 more months have passed.
> A
>
> "tcw" <tcwangs@.msn.com> wrote in message
> news:%23yZt9I4pGHA.4912@.TK2MSFTNGP05.phx.gbl...
>> How do I delete rows that are older than 180 days if the table does not
>> contain a column of timestamp? The following statement works fine if
>> parameter startdate is known:
>> DELETE From MyTable Where DATEDIFF (day, startdate, GETDATE()) > 180
>> Thanks in advance.
>> -tc
>|||"tcw" <tcwangs@.msn.com> wrote in message
news:egpsl9GqGHA.4932@.TK2MSFTNGP05.phx.gbl...
> Thank you very much, guys. I think I will add a timestamp column to my
table
> next time.
Note: To be perfectly clear, you wanta datetime (or smalldatetime) column.
Timestamp is a separate datatype which actually doesn't map to date or time.
> -tc
> "Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in
message
> news:eo6cup4pGHA.148@.TK2MSFTNGP04.phx.gbl...
> > SQL Server does not track this information, so you're going to have to
add
> > a column like:
> >
> > ALTER TABLE MyTable ADD CreatedDate SMALLDATETIME NOT NULL DEFAULT
> > CURRENT_TIMESTAMP;
> >
> > Of course, you won't be able to take advantage of the values for this
> > specifc task until 6 more months have passed.
> >
> > A
> >
> >
> > "tcw" <tcwangs@.msn.com> wrote in message
> > news:%23yZt9I4pGHA.4912@.TK2MSFTNGP05.phx.gbl...
> >> How do I delete rows that are older than 180 days if the table does not
> >> contain a column of timestamp? The following statement works fine if
> >> parameter startdate is known:
> >>
> >> DELETE From MyTable Where DATEDIFF (day, startdate, GETDATE()) > 180
> >>
> >> Thanks in advance.
> >>
> >> -tc
> >>
> >
> >
>sql
How to get the record created date?
How do I delete rows that are older than 180 days if the table does not
contain a column of timestamp? The following statement works fine if
parameter startdate is known:
DELETE From MyTable Where DATEDIFF (day, startdate, GETDATE()) > 180
Thanks in advance.
-tcYou don't. Unless you can join with another table that has a datetime
column. (Every table 'should' have such a column: RecordCreated datetime)
And 'timestamp' as the timestamp datatype has nothing to do with TIME.
--
Arnie Rowland
"To be successful, your heart must accompany your knowledge."
"tcw" <tcwangs@.msn.com> wrote in message
news:%23yZt9I4pGHA.4912@.TK2MSFTNGP05.phx.gbl...
> How do I delete rows that are older than 180 days if the table does not
> contain a column of timestamp? The following statement works fine if
> parameter startdate is known:
> DELETE From MyTable Where DATEDIFF (day, startdate, GETDATE()) > 180
> Thanks in advance.
> -tc
>|||SQL Server does not track this information, so you're going to have to add a
column like:
ALTER TABLE MyTable ADD CreatedDate SMALLDATETIME NOT NULL DEFAULT
CURRENT_TIMESTAMP;
Of course, you won't be able to take advantage of the values for this
specifc task until 6 more months have passed.
A
"tcw" <tcwangs@.msn.com> wrote in message
news:%23yZt9I4pGHA.4912@.TK2MSFTNGP05.phx.gbl...
> How do I delete rows that are older than 180 days if the table does not
> contain a column of timestamp? The following statement works fine if
> parameter startdate is known:
> DELETE From MyTable Where DATEDIFF (day, startdate, GETDATE()) > 180
> Thanks in advance.
> -tc
>|||> (Every table 'should' have such a column: RecordCreated datetime)
Whoa, that's a pretty broad generalization. Such a column is useful, but in
most applications it isn't necessary on every single table.
A|||Very True, but I prefer to drive home the point for the generalization, and
then once the idea has taken hold, start dealing with the exceptions. And of
course, not needed at all in some databases.
But for general business data ...
--
Arnie Rowland
"To be successful, your heart must accompany your knowledge."
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:epyLdq4pGHA.4812@.TK2MSFTNGP04.phx.gbl...
>> (Every table 'should' have such a column: RecordCreated datetime)
> Whoa, that's a pretty broad generalization. Such a column is useful, but
> in most applications it isn't necessary on every single table.
> A
>|||It would be better to drive home the fact that each row should take up as
little space as possible and then deal with the exceptions. That way you
encourage efficiency.
--
Best regards
Mark Baldwin
"Arnie Rowland" <arnie@.1568.com> wrote in message
news:eiBkZz4pGHA.4912@.TK2MSFTNGP05.phx.gbl...
> Very True, but I prefer to drive home the point for the generalization,
> and then once the idea has taken hold, start dealing with the exceptions.
> And of course, not needed at all in some databases.
> But for general business data ...
> --
> Arnie Rowland
> "To be successful, your heart must accompany your knowledge."
>
> "Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in
> message news:epyLdq4pGHA.4812@.TK2MSFTNGP04.phx.gbl...
>> (Every table 'should' have such a column: RecordCreated datetime)
>> Whoa, that's a pretty broad generalization. Such a column is useful, but
>> in most applications it isn't necessary on every single table.
>> A
>|||I'm less concerned with saving 4 or 8 bytes than with having a 'robust' data
system -I keep hearing storage is inexpensive. Perhaps it's just the segment
of large corporation and government agencies that I work with, but for the
last several years, all projects I've worked with have either required or
benefited from having not only a date column (entered/changed) -but also a
column capturing 'who' was responsible. And updates/deletes from selected
tables may be shadowed to an archive table/server. I tend to work with
VLDB's that must meet requirements set out by Aegis (law enforcement),
SarBox (financial), and/or HIPPA (medical).
Personally, I think that business systems 'should' have date and person
columns on almost every table. They solve so many of the 'problems' that
come up over a project's lifecycle. -Such as the one posted by the OP.
--
Arnie Rowland
"To be successful, your heart must accompany your knowledge."
"Mark" <swozz_@.hotmail.com> wrote in message
news:OT$O7e$pGHA.5064@.TK2MSFTNGP05.phx.gbl...
> It would be better to drive home the fact that each row should take up as
> little space as possible and then deal with the exceptions. That way you
> encourage efficiency.
> --
> Best regards
> Mark Baldwin
>
> "Arnie Rowland" <arnie@.1568.com> wrote in message
> news:eiBkZz4pGHA.4912@.TK2MSFTNGP05.phx.gbl...
>> Very True, but I prefer to drive home the point for the generalization,
>> and then once the idea has taken hold, start dealing with the exceptions.
>> And of course, not needed at all in some databases.
>> But for general business data ...
>> --
>> Arnie Rowland
>> "To be successful, your heart must accompany your knowledge."
>>
>> "Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in
>> message news:epyLdq4pGHA.4812@.TK2MSFTNGP04.phx.gbl...
>> (Every table 'should' have such a column: RecordCreated datetime)
>> Whoa, that's a pretty broad generalization. Such a column is useful,
>> but in most applications it isn't necessary on every single table.
>> A
>>
>|||> benefited from having not only a date column (entered/changed) -but also
> a column capturing 'who' was responsible.
That kind of data, imho, belongs in a separate auditing table.
Otherwise, you are forced to either have really wide tables or only track
the LAST person who changed it.
> Personally, I think that business systems 'should' have date and person
> columns on almost every table.
I think for higher level entities that's not a bad idea. For complex OLTP
systems with hundreds of tables, you're going to drown yourself in
information overload.
A|||Thank you very much, guys. I think I will add a timestamp column to my table
next time.
-tc
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:eo6cup4pGHA.148@.TK2MSFTNGP04.phx.gbl...
> SQL Server does not track this information, so you're going to have to add
> a column like:
> ALTER TABLE MyTable ADD CreatedDate SMALLDATETIME NOT NULL DEFAULT
> CURRENT_TIMESTAMP;
> Of course, you won't be able to take advantage of the values for this
> specifc task until 6 more months have passed.
> A
>
> "tcw" <tcwangs@.msn.com> wrote in message
> news:%23yZt9I4pGHA.4912@.TK2MSFTNGP05.phx.gbl...
>> How do I delete rows that are older than 180 days if the table does not
>> contain a column of timestamp? The following statement works fine if
>> parameter startdate is known:
>> DELETE From MyTable Where DATEDIFF (day, startdate, GETDATE()) > 180
>> Thanks in advance.
>> -tc
>|||"tcw" <tcwangs@.msn.com> wrote in message
news:egpsl9GqGHA.4932@.TK2MSFTNGP05.phx.gbl...
> Thank you very much, guys. I think I will add a timestamp column to my
table
> next time.
Note: To be perfectly clear, you wanta datetime (or smalldatetime) column.
Timestamp is a separate datatype which actually doesn't map to date or time.
> -tc
> "Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in
message
> news:eo6cup4pGHA.148@.TK2MSFTNGP04.phx.gbl...
> > SQL Server does not track this information, so you're going to have to
add
> > a column like:
> >
> > ALTER TABLE MyTable ADD CreatedDate SMALLDATETIME NOT NULL DEFAULT
> > CURRENT_TIMESTAMP;
> >
> > Of course, you won't be able to take advantage of the values for this
> > specifc task until 6 more months have passed.
> >
> > A
> >
> >
> > "tcw" <tcwangs@.msn.com> wrote in message
> > news:%23yZt9I4pGHA.4912@.TK2MSFTNGP05.phx.gbl...
> >> How do I delete rows that are older than 180 days if the table does not
> >> contain a column of timestamp? The following statement works fine if
> >> parameter startdate is known:
> >>
> >> DELETE From MyTable Where DATEDIFF (day, startdate, GETDATE()) > 180
> >>
> >> Thanks in advance.
> >>
> >> -tc
> >>
> >
> >
>
contain a column of timestamp? The following statement works fine if
parameter startdate is known:
DELETE From MyTable Where DATEDIFF (day, startdate, GETDATE()) > 180
Thanks in advance.
-tcYou don't. Unless you can join with another table that has a datetime
column. (Every table 'should' have such a column: RecordCreated datetime)
And 'timestamp' as the timestamp datatype has nothing to do with TIME.
--
Arnie Rowland
"To be successful, your heart must accompany your knowledge."
"tcw" <tcwangs@.msn.com> wrote in message
news:%23yZt9I4pGHA.4912@.TK2MSFTNGP05.phx.gbl...
> How do I delete rows that are older than 180 days if the table does not
> contain a column of timestamp? The following statement works fine if
> parameter startdate is known:
> DELETE From MyTable Where DATEDIFF (day, startdate, GETDATE()) > 180
> Thanks in advance.
> -tc
>|||SQL Server does not track this information, so you're going to have to add a
column like:
ALTER TABLE MyTable ADD CreatedDate SMALLDATETIME NOT NULL DEFAULT
CURRENT_TIMESTAMP;
Of course, you won't be able to take advantage of the values for this
specifc task until 6 more months have passed.
A
"tcw" <tcwangs@.msn.com> wrote in message
news:%23yZt9I4pGHA.4912@.TK2MSFTNGP05.phx.gbl...
> How do I delete rows that are older than 180 days if the table does not
> contain a column of timestamp? The following statement works fine if
> parameter startdate is known:
> DELETE From MyTable Where DATEDIFF (day, startdate, GETDATE()) > 180
> Thanks in advance.
> -tc
>|||> (Every table 'should' have such a column: RecordCreated datetime)
Whoa, that's a pretty broad generalization. Such a column is useful, but in
most applications it isn't necessary on every single table.
A|||Very True, but I prefer to drive home the point for the generalization, and
then once the idea has taken hold, start dealing with the exceptions. And of
course, not needed at all in some databases.
But for general business data ...
--
Arnie Rowland
"To be successful, your heart must accompany your knowledge."
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:epyLdq4pGHA.4812@.TK2MSFTNGP04.phx.gbl...
>> (Every table 'should' have such a column: RecordCreated datetime)
> Whoa, that's a pretty broad generalization. Such a column is useful, but
> in most applications it isn't necessary on every single table.
> A
>|||It would be better to drive home the fact that each row should take up as
little space as possible and then deal with the exceptions. That way you
encourage efficiency.
--
Best regards
Mark Baldwin
"Arnie Rowland" <arnie@.1568.com> wrote in message
news:eiBkZz4pGHA.4912@.TK2MSFTNGP05.phx.gbl...
> Very True, but I prefer to drive home the point for the generalization,
> and then once the idea has taken hold, start dealing with the exceptions.
> And of course, not needed at all in some databases.
> But for general business data ...
> --
> Arnie Rowland
> "To be successful, your heart must accompany your knowledge."
>
> "Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in
> message news:epyLdq4pGHA.4812@.TK2MSFTNGP04.phx.gbl...
>> (Every table 'should' have such a column: RecordCreated datetime)
>> Whoa, that's a pretty broad generalization. Such a column is useful, but
>> in most applications it isn't necessary on every single table.
>> A
>|||I'm less concerned with saving 4 or 8 bytes than with having a 'robust' data
system -I keep hearing storage is inexpensive. Perhaps it's just the segment
of large corporation and government agencies that I work with, but for the
last several years, all projects I've worked with have either required or
benefited from having not only a date column (entered/changed) -but also a
column capturing 'who' was responsible. And updates/deletes from selected
tables may be shadowed to an archive table/server. I tend to work with
VLDB's that must meet requirements set out by Aegis (law enforcement),
SarBox (financial), and/or HIPPA (medical).
Personally, I think that business systems 'should' have date and person
columns on almost every table. They solve so many of the 'problems' that
come up over a project's lifecycle. -Such as the one posted by the OP.
--
Arnie Rowland
"To be successful, your heart must accompany your knowledge."
"Mark" <swozz_@.hotmail.com> wrote in message
news:OT$O7e$pGHA.5064@.TK2MSFTNGP05.phx.gbl...
> It would be better to drive home the fact that each row should take up as
> little space as possible and then deal with the exceptions. That way you
> encourage efficiency.
> --
> Best regards
> Mark Baldwin
>
> "Arnie Rowland" <arnie@.1568.com> wrote in message
> news:eiBkZz4pGHA.4912@.TK2MSFTNGP05.phx.gbl...
>> Very True, but I prefer to drive home the point for the generalization,
>> and then once the idea has taken hold, start dealing with the exceptions.
>> And of course, not needed at all in some databases.
>> But for general business data ...
>> --
>> Arnie Rowland
>> "To be successful, your heart must accompany your knowledge."
>>
>> "Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in
>> message news:epyLdq4pGHA.4812@.TK2MSFTNGP04.phx.gbl...
>> (Every table 'should' have such a column: RecordCreated datetime)
>> Whoa, that's a pretty broad generalization. Such a column is useful,
>> but in most applications it isn't necessary on every single table.
>> A
>>
>|||> benefited from having not only a date column (entered/changed) -but also
> a column capturing 'who' was responsible.
That kind of data, imho, belongs in a separate auditing table.
Otherwise, you are forced to either have really wide tables or only track
the LAST person who changed it.
> Personally, I think that business systems 'should' have date and person
> columns on almost every table.
I think for higher level entities that's not a bad idea. For complex OLTP
systems with hundreds of tables, you're going to drown yourself in
information overload.
A|||Thank you very much, guys. I think I will add a timestamp column to my table
next time.
-tc
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:eo6cup4pGHA.148@.TK2MSFTNGP04.phx.gbl...
> SQL Server does not track this information, so you're going to have to add
> a column like:
> ALTER TABLE MyTable ADD CreatedDate SMALLDATETIME NOT NULL DEFAULT
> CURRENT_TIMESTAMP;
> Of course, you won't be able to take advantage of the values for this
> specifc task until 6 more months have passed.
> A
>
> "tcw" <tcwangs@.msn.com> wrote in message
> news:%23yZt9I4pGHA.4912@.TK2MSFTNGP05.phx.gbl...
>> How do I delete rows that are older than 180 days if the table does not
>> contain a column of timestamp? The following statement works fine if
>> parameter startdate is known:
>> DELETE From MyTable Where DATEDIFF (day, startdate, GETDATE()) > 180
>> Thanks in advance.
>> -tc
>|||"tcw" <tcwangs@.msn.com> wrote in message
news:egpsl9GqGHA.4932@.TK2MSFTNGP05.phx.gbl...
> Thank you very much, guys. I think I will add a timestamp column to my
table
> next time.
Note: To be perfectly clear, you wanta datetime (or smalldatetime) column.
Timestamp is a separate datatype which actually doesn't map to date or time.
> -tc
> "Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in
message
> news:eo6cup4pGHA.148@.TK2MSFTNGP04.phx.gbl...
> > SQL Server does not track this information, so you're going to have to
add
> > a column like:
> >
> > ALTER TABLE MyTable ADD CreatedDate SMALLDATETIME NOT NULL DEFAULT
> > CURRENT_TIMESTAMP;
> >
> > Of course, you won't be able to take advantage of the values for this
> > specifc task until 6 more months have passed.
> >
> > A
> >
> >
> > "tcw" <tcwangs@.msn.com> wrote in message
> > news:%23yZt9I4pGHA.4912@.TK2MSFTNGP05.phx.gbl...
> >> How do I delete rows that are older than 180 days if the table does not
> >> contain a column of timestamp? The following statement works fine if
> >> parameter startdate is known:
> >>
> >> DELETE From MyTable Where DATEDIFF (day, startdate, GETDATE()) > 180
> >>
> >> Thanks in advance.
> >>
> >> -tc
> >>
> >
> >
>
Friday, March 23, 2012
how to get the date 2years before
Hi
Can anyone please help me to get the date that is 2 years before .
So that i can pull put the records tht are 2 years older...
Can anyone please help me to get the date that is 2 years before .
So that i can pull put the records tht are 2 years older...
i want to use it in a query ...
Thanks in advanceUse this select dateadd(yy, -2, getdate())
or in quesry
where date < dateadd(yy, -2, getdate())
Good Luck.sql
Sunday, February 19, 2012
How to get free space
Hi,
SQL2K, Win 2k.
I am trying to acquire space by deleting older records from a table.
When I ran sp_spaceused on a Table A, I got following output
Table A
rows: 145030470
reserved: 139653704 KB
data: 81832616 KB= 78GB
index_size: 23655616 KB = 22.5
unused: 34165472 KB
Afte that I had deleted around 60 million records based on certain criteria.
I thought I will get atleast 30GB free space. But when I checked in EM > task
pad, I only see around 14GB free space.
Is there anyway to get free space from the pages?
Thanks in advance
Chinna.
See BOL... DBCC Shrinkfile
"Chinna Kondaveeti" wrote:
> Hi,
> SQL2K, Win 2k.
> I am trying to acquire space by deleting older records from a table.
> When I ran sp_spaceused on a Table A, I got following output
> Table A
> rows: 145030470
> reserved: 139653704 KB
> data: 81832616 KB= 78GB
> index_size: 23655616 KB = 22.5
> unused: 34165472 KB
> Afte that I had deleted around 60 million records based on certain criteria.
> I thought I will get atleast 30GB free space. But when I checked in EM > task
> pad, I only see around 14GB free space.
> Is there anyway to get free space from the pages?
> Thanks in advance
> Chinna.
>
|||Thanks for the reply. I ran dbcc shrinkfile to get that 14GB free space. What
I am trying to say is, based on the size estimation, there should have been
more than 14GB free space. But I don't see that in the task pad view. Is
there any way to reorganize the pages/db files to get the remaining space?
Thanks in advance
Chinna.
"Wex" wrote:
[vbcol=seagreen]
> See BOL... DBCC Shrinkfile
> "Chinna Kondaveeti" wrote:
|||Does the table have a Clustered Index? If so use DBCC SHOWCONTIG to see the
level of fragmentation. You can use DBCC INDEXDEFRAG to defragment the
index. Watch out for performance drop of while defraging
"Chinna Kondaveeti" wrote:
[vbcol=seagreen]
> Thanks for the reply. I ran dbcc shrinkfile to get that 14GB free space. What
> I am trying to say is, based on the size estimation, there should have been
> more than 14GB free space. But I don't see that in the task pad view. Is
> there any way to reorganize the pages/db files to get the remaining space?
> Thanks in advance
> Chinna.
> "Wex" wrote:
|||Chinna,
Do you have text or image column? If you do then you will have issues
reclaming all the space.
Did you use truncate option or noturncate option. There is a difference in
the way these work.
"Chinna Kondaveeti" <ChinnaKondaveeti@.discussions.microsoft.com> wrote in
message news:4DA0D6E0-E353-4751-A485-817CBD4A53E7@.microsoft.com...
> Thanks for the reply. I ran dbcc shrinkfile to get that 14GB free space.
What
> I am trying to say is, based on the size estimation, there should have
been[vbcol=seagreen]
> more than 14GB free space. But I don't see that in the task pad view. Is
> there any way to reorganize the pages/db files to get the remaining space?
> Thanks in advance
> Chinna.
> "Wex" wrote:
criteria.[vbcol=seagreen]
> task
SQL2K, Win 2k.
I am trying to acquire space by deleting older records from a table.
When I ran sp_spaceused on a Table A, I got following output
Table A
rows: 145030470
reserved: 139653704 KB
data: 81832616 KB= 78GB
index_size: 23655616 KB = 22.5
unused: 34165472 KB
Afte that I had deleted around 60 million records based on certain criteria.
I thought I will get atleast 30GB free space. But when I checked in EM > task
pad, I only see around 14GB free space.
Is there anyway to get free space from the pages?
Thanks in advance
Chinna.
See BOL... DBCC Shrinkfile
"Chinna Kondaveeti" wrote:
> Hi,
> SQL2K, Win 2k.
> I am trying to acquire space by deleting older records from a table.
> When I ran sp_spaceused on a Table A, I got following output
> Table A
> rows: 145030470
> reserved: 139653704 KB
> data: 81832616 KB= 78GB
> index_size: 23655616 KB = 22.5
> unused: 34165472 KB
> Afte that I had deleted around 60 million records based on certain criteria.
> I thought I will get atleast 30GB free space. But when I checked in EM > task
> pad, I only see around 14GB free space.
> Is there anyway to get free space from the pages?
> Thanks in advance
> Chinna.
>
|||Thanks for the reply. I ran dbcc shrinkfile to get that 14GB free space. What
I am trying to say is, based on the size estimation, there should have been
more than 14GB free space. But I don't see that in the task pad view. Is
there any way to reorganize the pages/db files to get the remaining space?
Thanks in advance
Chinna.
"Wex" wrote:
[vbcol=seagreen]
> See BOL... DBCC Shrinkfile
> "Chinna Kondaveeti" wrote:
|||Does the table have a Clustered Index? If so use DBCC SHOWCONTIG to see the
level of fragmentation. You can use DBCC INDEXDEFRAG to defragment the
index. Watch out for performance drop of while defraging
"Chinna Kondaveeti" wrote:
[vbcol=seagreen]
> Thanks for the reply. I ran dbcc shrinkfile to get that 14GB free space. What
> I am trying to say is, based on the size estimation, there should have been
> more than 14GB free space. But I don't see that in the task pad view. Is
> there any way to reorganize the pages/db files to get the remaining space?
> Thanks in advance
> Chinna.
> "Wex" wrote:
|||Chinna,
Do you have text or image column? If you do then you will have issues
reclaming all the space.
Did you use truncate option or noturncate option. There is a difference in
the way these work.
"Chinna Kondaveeti" <ChinnaKondaveeti@.discussions.microsoft.com> wrote in
message news:4DA0D6E0-E353-4751-A485-817CBD4A53E7@.microsoft.com...
> Thanks for the reply. I ran dbcc shrinkfile to get that 14GB free space.
What
> I am trying to say is, based on the size estimation, there should have
been[vbcol=seagreen]
> more than 14GB free space. But I don't see that in the task pad view. Is
> there any way to reorganize the pages/db files to get the remaining space?
> Thanks in advance
> Chinna.
> "Wex" wrote:
criteria.[vbcol=seagreen]
> task
How to get free space
Hi,
SQL2K, Win 2k.
I am trying to acquire space by deleting older records from a table.
When I ran sp_spaceused on a Table A, I got following output
Table A
rows: 145030470
reserved: 139653704 KB
data: 81832616 KB = 78GB
index_size: 23655616 KB = 22.5
unused: 34165472 KB
Afte that I had deleted around 60 million records based on certain criteria.
I thought I will get atleast 30GB free space. But when I checked in EM > tas
k
pad, I only see around 14GB free space.
Is there anyway to get free space from the pages?
Thanks in advance
Chinna.See BOL... DBCC Shrinkfile
"Chinna Kondaveeti" wrote:
> Hi,
> SQL2K, Win 2k.
> I am trying to acquire space by deleting older records from a table.
> When I ran sp_spaceused on a Table A, I got following output
> Table A
> rows: 145030470
> reserved: 139653704 KB
> data: 81832616 KB = 78GB
> index_size: 23655616 KB = 22.5
> unused: 34165472 KB
> Afte that I had deleted around 60 million records based on certain criteri
a.
> I thought I will get atleast 30GB free space. But when I checked in EM > t
ask
> pad, I only see around 14GB free space.
> Is there anyway to get free space from the pages?
> Thanks in advance
> Chinna.
>|||Thanks for the reply. I ran dbcc shrinkfile to get that 14GB free space. Wha
t
I am trying to say is, based on the size estimation, there should have been
more than 14GB free space. But I don't see that in the task pad view. Is
there any way to reorganize the pages/db files to get the remaining space?
Thanks in advance
Chinna.
"Wex" wrote:
[vbcol=seagreen]
> See BOL... DBCC Shrinkfile
> "Chinna Kondaveeti" wrote:
>|||Does the table have a Clustered Index? If so use DBCC SHOWCONTIG to see the
level of fragmentation. You can use DBCC INDEXDEFRAG to defragment the
index. Watch out for performance drop of while defraging
"Chinna Kondaveeti" wrote:
[vbcol=seagreen]
> Thanks for the reply. I ran dbcc shrinkfile to get that 14GB free space. W
hat
> I am trying to say is, based on the size estimation, there should have bee
n
> more than 14GB free space. But I don't see that in the task pad view. Is
> there any way to reorganize the pages/db files to get the remaining space?
> Thanks in advance
> Chinna.
> "Wex" wrote:
>|||Chinna,
Do you have text or image column? If you do then you will have issues
reclaming all the space.
Did you use truncate option or noturncate option. There is a difference in
the way these work.
"Chinna Kondaveeti" <ChinnaKondaveeti@.discussions.microsoft.com> wrote in
message news:4DA0D6E0-E353-4751-A485-817CBD4A53E7@.microsoft.com...
> Thanks for the reply. I ran dbcc shrinkfile to get that 14GB free space.
What
> I am trying to say is, based on the size estimation, there should have
been[vbcol=seagreen]
> more than 14GB free space. But I don't see that in the task pad view. Is
> there any way to reorganize the pages/db files to get the remaining space?
> Thanks in advance
> Chinna.
> "Wex" wrote:
>
criteria.[vbcol=seagreen]
> task
SQL2K, Win 2k.
I am trying to acquire space by deleting older records from a table.
When I ran sp_spaceused on a Table A, I got following output
Table A
rows: 145030470
reserved: 139653704 KB
data: 81832616 KB = 78GB
index_size: 23655616 KB = 22.5
unused: 34165472 KB
Afte that I had deleted around 60 million records based on certain criteria.
I thought I will get atleast 30GB free space. But when I checked in EM > tas
k
pad, I only see around 14GB free space.
Is there anyway to get free space from the pages?
Thanks in advance
Chinna.See BOL... DBCC Shrinkfile
"Chinna Kondaveeti" wrote:
> Hi,
> SQL2K, Win 2k.
> I am trying to acquire space by deleting older records from a table.
> When I ran sp_spaceused on a Table A, I got following output
> Table A
> rows: 145030470
> reserved: 139653704 KB
> data: 81832616 KB = 78GB
> index_size: 23655616 KB = 22.5
> unused: 34165472 KB
> Afte that I had deleted around 60 million records based on certain criteri
a.
> I thought I will get atleast 30GB free space. But when I checked in EM > t
ask
> pad, I only see around 14GB free space.
> Is there anyway to get free space from the pages?
> Thanks in advance
> Chinna.
>|||Thanks for the reply. I ran dbcc shrinkfile to get that 14GB free space. Wha
t
I am trying to say is, based on the size estimation, there should have been
more than 14GB free space. But I don't see that in the task pad view. Is
there any way to reorganize the pages/db files to get the remaining space?
Thanks in advance
Chinna.
"Wex" wrote:
[vbcol=seagreen]
> See BOL... DBCC Shrinkfile
> "Chinna Kondaveeti" wrote:
>|||Does the table have a Clustered Index? If so use DBCC SHOWCONTIG to see the
level of fragmentation. You can use DBCC INDEXDEFRAG to defragment the
index. Watch out for performance drop of while defraging
"Chinna Kondaveeti" wrote:
[vbcol=seagreen]
> Thanks for the reply. I ran dbcc shrinkfile to get that 14GB free space. W
hat
> I am trying to say is, based on the size estimation, there should have bee
n
> more than 14GB free space. But I don't see that in the task pad view. Is
> there any way to reorganize the pages/db files to get the remaining space?
> Thanks in advance
> Chinna.
> "Wex" wrote:
>|||Chinna,
Do you have text or image column? If you do then you will have issues
reclaming all the space.
Did you use truncate option or noturncate option. There is a difference in
the way these work.
"Chinna Kondaveeti" <ChinnaKondaveeti@.discussions.microsoft.com> wrote in
message news:4DA0D6E0-E353-4751-A485-817CBD4A53E7@.microsoft.com...
> Thanks for the reply. I ran dbcc shrinkfile to get that 14GB free space.
What
> I am trying to say is, based on the size estimation, there should have
been[vbcol=seagreen]
> more than 14GB free space. But I don't see that in the task pad view. Is
> there any way to reorganize the pages/db files to get the remaining space?
> Thanks in advance
> Chinna.
> "Wex" wrote:
>
criteria.[vbcol=seagreen]
> task
How to get free space
Hi,
SQL2K, Win 2k.
I am trying to acquire space by deleting older records from a table.
When I ran sp_spaceused on a Table A, I got following output
Table A
rows: 145030470
reserved: 139653704 KB
data: 81832616 KB = 78GB
index_size: 23655616 KB = 22.5
unused: 34165472 KB
Afte that I had deleted around 60 million records based on certain criteria.
I thought I will get atleast 30GB free space. But when I checked in EM > task
pad, I only see around 14GB free space.
Is there anyway to get free space from the pages?
Thanks in advance
Chinna.See BOL... DBCC Shrinkfile
"Chinna Kondaveeti" wrote:
> Hi,
> SQL2K, Win 2k.
> I am trying to acquire space by deleting older records from a table.
> When I ran sp_spaceused on a Table A, I got following output
> Table A
> rows: 145030470
> reserved: 139653704 KB
> data: 81832616 KB = 78GB
> index_size: 23655616 KB = 22.5
> unused: 34165472 KB
> Afte that I had deleted around 60 million records based on certain criteria.
> I thought I will get atleast 30GB free space. But when I checked in EM > task
> pad, I only see around 14GB free space.
> Is there anyway to get free space from the pages?
> Thanks in advance
> Chinna.
>|||Thanks for the reply. I ran dbcc shrinkfile to get that 14GB free space. What
I am trying to say is, based on the size estimation, there should have been
more than 14GB free space. But I don't see that in the task pad view. Is
there any way to reorganize the pages/db files to get the remaining space?
Thanks in advance
Chinna.
"Wex" wrote:
> See BOL... DBCC Shrinkfile
> "Chinna Kondaveeti" wrote:
> > Hi,
> > SQL2K, Win 2k.
> > I am trying to acquire space by deleting older records from a table.
> > When I ran sp_spaceused on a Table A, I got following output
> >
> > Table A
> > rows: 145030470
> > reserved: 139653704 KB
> > data: 81832616 KB = 78GB
> > index_size: 23655616 KB = 22.5
> > unused: 34165472 KB
> >
> > Afte that I had deleted around 60 million records based on certain criteria.
> > I thought I will get atleast 30GB free space. But when I checked in EM > task
> > pad, I only see around 14GB free space.
> >
> > Is there anyway to get free space from the pages?
> >
> > Thanks in advance
> > Chinna.
> >
> >|||Does the table have a Clustered Index? If so use DBCC SHOWCONTIG to see the
level of fragmentation. You can use DBCC INDEXDEFRAG to defragment the
index. Watch out for performance drop of while defraging
"Chinna Kondaveeti" wrote:
> Thanks for the reply. I ran dbcc shrinkfile to get that 14GB free space. What
> I am trying to say is, based on the size estimation, there should have been
> more than 14GB free space. But I don't see that in the task pad view. Is
> there any way to reorganize the pages/db files to get the remaining space?
> Thanks in advance
> Chinna.
> "Wex" wrote:
> > See BOL... DBCC Shrinkfile
> >
> > "Chinna Kondaveeti" wrote:
> >
> > > Hi,
> > > SQL2K, Win 2k.
> > > I am trying to acquire space by deleting older records from a table.
> > > When I ran sp_spaceused on a Table A, I got following output
> > >
> > > Table A
> > > rows: 145030470
> > > reserved: 139653704 KB
> > > data: 81832616 KB = 78GB
> > > index_size: 23655616 KB = 22.5
> > > unused: 34165472 KB
> > >
> > > Afte that I had deleted around 60 million records based on certain criteria.
> > > I thought I will get atleast 30GB free space. But when I checked in EM > task
> > > pad, I only see around 14GB free space.
> > >
> > > Is there anyway to get free space from the pages?
> > >
> > > Thanks in advance
> > > Chinna.
> > >
> > >|||Chinna,
Do you have text or image column? If you do then you will have issues
reclaming all the space.
Did you use truncate option or noturncate option. There is a difference in
the way these work.
"Chinna Kondaveeti" <ChinnaKondaveeti@.discussions.microsoft.com> wrote in
message news:4DA0D6E0-E353-4751-A485-817CBD4A53E7@.microsoft.com...
> Thanks for the reply. I ran dbcc shrinkfile to get that 14GB free space.
What
> I am trying to say is, based on the size estimation, there should have
been
> more than 14GB free space. But I don't see that in the task pad view. Is
> there any way to reorganize the pages/db files to get the remaining space?
> Thanks in advance
> Chinna.
> "Wex" wrote:
> > See BOL... DBCC Shrinkfile
> >
> > "Chinna Kondaveeti" wrote:
> >
> > > Hi,
> > > SQL2K, Win 2k.
> > > I am trying to acquire space by deleting older records from a table.
> > > When I ran sp_spaceused on a Table A, I got following output
> > >
> > > Table A
> > > rows: 145030470
> > > reserved: 139653704 KB
> > > data: 81832616 KB = 78GB
> > > index_size: 23655616 KB = 22.5
> > > unused: 34165472 KB
> > >
> > > Afte that I had deleted around 60 million records based on certain
criteria.
> > > I thought I will get atleast 30GB free space. But when I checked in EM
> task
> > > pad, I only see around 14GB free space.
> > >
> > > Is there anyway to get free space from the pages?
> > >
> > > Thanks in advance
> > > Chinna.
> > >
> > >
SQL2K, Win 2k.
I am trying to acquire space by deleting older records from a table.
When I ran sp_spaceused on a Table A, I got following output
Table A
rows: 145030470
reserved: 139653704 KB
data: 81832616 KB = 78GB
index_size: 23655616 KB = 22.5
unused: 34165472 KB
Afte that I had deleted around 60 million records based on certain criteria.
I thought I will get atleast 30GB free space. But when I checked in EM > task
pad, I only see around 14GB free space.
Is there anyway to get free space from the pages?
Thanks in advance
Chinna.See BOL... DBCC Shrinkfile
"Chinna Kondaveeti" wrote:
> Hi,
> SQL2K, Win 2k.
> I am trying to acquire space by deleting older records from a table.
> When I ran sp_spaceused on a Table A, I got following output
> Table A
> rows: 145030470
> reserved: 139653704 KB
> data: 81832616 KB = 78GB
> index_size: 23655616 KB = 22.5
> unused: 34165472 KB
> Afte that I had deleted around 60 million records based on certain criteria.
> I thought I will get atleast 30GB free space. But when I checked in EM > task
> pad, I only see around 14GB free space.
> Is there anyway to get free space from the pages?
> Thanks in advance
> Chinna.
>|||Thanks for the reply. I ran dbcc shrinkfile to get that 14GB free space. What
I am trying to say is, based on the size estimation, there should have been
more than 14GB free space. But I don't see that in the task pad view. Is
there any way to reorganize the pages/db files to get the remaining space?
Thanks in advance
Chinna.
"Wex" wrote:
> See BOL... DBCC Shrinkfile
> "Chinna Kondaveeti" wrote:
> > Hi,
> > SQL2K, Win 2k.
> > I am trying to acquire space by deleting older records from a table.
> > When I ran sp_spaceused on a Table A, I got following output
> >
> > Table A
> > rows: 145030470
> > reserved: 139653704 KB
> > data: 81832616 KB = 78GB
> > index_size: 23655616 KB = 22.5
> > unused: 34165472 KB
> >
> > Afte that I had deleted around 60 million records based on certain criteria.
> > I thought I will get atleast 30GB free space. But when I checked in EM > task
> > pad, I only see around 14GB free space.
> >
> > Is there anyway to get free space from the pages?
> >
> > Thanks in advance
> > Chinna.
> >
> >|||Does the table have a Clustered Index? If so use DBCC SHOWCONTIG to see the
level of fragmentation. You can use DBCC INDEXDEFRAG to defragment the
index. Watch out for performance drop of while defraging
"Chinna Kondaveeti" wrote:
> Thanks for the reply. I ran dbcc shrinkfile to get that 14GB free space. What
> I am trying to say is, based on the size estimation, there should have been
> more than 14GB free space. But I don't see that in the task pad view. Is
> there any way to reorganize the pages/db files to get the remaining space?
> Thanks in advance
> Chinna.
> "Wex" wrote:
> > See BOL... DBCC Shrinkfile
> >
> > "Chinna Kondaveeti" wrote:
> >
> > > Hi,
> > > SQL2K, Win 2k.
> > > I am trying to acquire space by deleting older records from a table.
> > > When I ran sp_spaceused on a Table A, I got following output
> > >
> > > Table A
> > > rows: 145030470
> > > reserved: 139653704 KB
> > > data: 81832616 KB = 78GB
> > > index_size: 23655616 KB = 22.5
> > > unused: 34165472 KB
> > >
> > > Afte that I had deleted around 60 million records based on certain criteria.
> > > I thought I will get atleast 30GB free space. But when I checked in EM > task
> > > pad, I only see around 14GB free space.
> > >
> > > Is there anyway to get free space from the pages?
> > >
> > > Thanks in advance
> > > Chinna.
> > >
> > >|||Chinna,
Do you have text or image column? If you do then you will have issues
reclaming all the space.
Did you use truncate option or noturncate option. There is a difference in
the way these work.
"Chinna Kondaveeti" <ChinnaKondaveeti@.discussions.microsoft.com> wrote in
message news:4DA0D6E0-E353-4751-A485-817CBD4A53E7@.microsoft.com...
> Thanks for the reply. I ran dbcc shrinkfile to get that 14GB free space.
What
> I am trying to say is, based on the size estimation, there should have
been
> more than 14GB free space. But I don't see that in the task pad view. Is
> there any way to reorganize the pages/db files to get the remaining space?
> Thanks in advance
> Chinna.
> "Wex" wrote:
> > See BOL... DBCC Shrinkfile
> >
> > "Chinna Kondaveeti" wrote:
> >
> > > Hi,
> > > SQL2K, Win 2k.
> > > I am trying to acquire space by deleting older records from a table.
> > > When I ran sp_spaceused on a Table A, I got following output
> > >
> > > Table A
> > > rows: 145030470
> > > reserved: 139653704 KB
> > > data: 81832616 KB = 78GB
> > > index_size: 23655616 KB = 22.5
> > > unused: 34165472 KB
> > >
> > > Afte that I had deleted around 60 million records based on certain
criteria.
> > > I thought I will get atleast 30GB free space. But when I checked in EM
> task
> > > pad, I only see around 14GB free space.
> > >
> > > Is there anyway to get free space from the pages?
> > >
> > > Thanks in advance
> > > Chinna.
> > >
> > >
Subscribe to:
Posts (Atom)