Thursday, March 22, 2012

Deleting empty rows from table

Please can someone provide a T-SQL command that will delete empty rows from
a
table
ThanksHuh? A row cannot exist if it is empty.
By definition a row is made up of data.
Perhaps you want to delete all rows where a specific column is empty (NULL).
If that is the case this should get you started:
/*
Identify the rows that you are about to delete
*/
SELECT * FROM YourTableNameGoesHere WHERE TheEmptyColumnNameGoesHere IS NULL
/*
Delete the rows
DELETE FROM YourTableNameGoesHere WHERE TheEmptyColumnNameGoesHere IS NULL
*/
Keith
"airforce1" <airforce1@.discussions.microsoft.com> wrote in message
news:AC7D6FEF-0743-4EE6-AD8B-F5DB008AF36D@.microsoft.com...
> Please can someone provide a T-SQL command that will delete empty rows
from a
> table
> Thanks|||Hi,Keith
I think the OP was mentioned to delete the rows which are =' ' ,wasn't he?
"Keith Kratochvil" <sqlguy.back2u@.comcast.net> wrote in message
news:u6Hpqkt1EHA.304@.TK2MSFTNGP11.phx.gbl...
> Huh? A row cannot exist if it is empty.
> By definition a row is made up of data.
> Perhaps you want to delete all rows where a specific column is empty
(NULL).
> If that is the case this should get you started:
> /*
> Identify the rows that you are about to delete
> */
> SELECT * FROM YourTableNameGoesHere WHERE TheEmptyColumnNameGoesHere IS
NULL
> /*
> Delete the rows
> DELETE FROM YourTableNameGoesHere WHERE TheEmptyColumnNameGoesHere IS NULL
> */
> --
> Keith
>
> "airforce1" <airforce1@.discussions.microsoft.com> wrote in message
> news:AC7D6FEF-0743-4EE6-AD8B-F5DB008AF36D@.microsoft.com...
> from a
>|||The original poster did not post a very well written question, so it is
difficult to provide a good answer.
<quote>
Please can someone provide a T-SQL command that will delete empty rows from
a
table
Thanks
</quote>
Keith
"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:%239Md5vu1EHA.804@.TK2MSFTNGP12.phx.gbl...
> Hi,Keith
> I think the OP was mentioned to delete the rows which are =' ' ,wasn't he?
>
>
> "Keith Kratochvil" <sqlguy.back2u@.comcast.net> wrote in message
> news:u6Hpqkt1EHA.304@.TK2MSFTNGP11.phx.gbl...
> (NULL).
> NULL
NULL[vbcol=seagreen]
>|||I suppose you can identify rows you want to delete. Maybe you want to delete
*identical* rows which can't be deleted though an error message (because the
database can't delete identical rows).
If it's the problem you are asking for, so add an autoincrement field in
your table and then repeat rows deletion.
In other case specify details ...
Vlastik
"airforce1" <airforce1@.discussions.microsoft.com> pe v diskusnm pspvku
news:AC7D6FEF-0743-4EE6-AD8B-F5DB008AF36D@.microsoft.com...
> Please can someone provide a T-SQL command that will delete empty rows
from a
> table
> Thanks

No comments:

Post a Comment