question

maaz88 avatar image
maaz88 asked

Deleting blank rows from sql server 2005 table.

I have a table named BatchHistory which has about 3500 entries. I could not sort it datewise although it has columns for start date and end date but still the "select" query for sort does not work for the latest 2013 entries. So, I have made another table named CHistory and manually copy pasted the 2013 entries in that table through ctrl+c and ctrl+v, but problem is that, it hasnt copied a lot of rows from BatchHistory through this method a red icon appears while pasting, and some blank rows are also copied which I am unable to delete, it gives error unable to delete. Please help as it does not read any data after a blank row in the CHistory table.
tables
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Grant Fritchey avatar image
Grant Fritchey answered
First off, stop using whatever GUI it is that you're using to manipulate the data. Go to T-SQL. That's the language you need to master to properly control SQL Server. When you say the sort doesn't work, you need to look at the statement ORDER BY and then provide the correct column. You can put it into an ascending or descending mode by adding ASC or DSC after the column name. That always works. If it's not working how you expect, you need to look to your data. To delete 'blank' rows, you can use a delete statement that looks for NULL values in a column. But, from the sounds of things, the values may not be NULL but might be empty strings. In this case you can try searching for values that equal ''. That's two single quote marks together, showing an empty string.
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

ThomasRushton avatar image ThomasRushton ♦♦ commented ·
Man, I wish I could give this more than just 1 upvote...
0 Likes 0 ·
ThomasRushton avatar image
ThomasRushton answered
Are you trying to do all that in the SSMS GUI without issuing the appropriate T-SQL commands yourself? That's a sure-fire way to disaster. The GUI was not designed for this sort of activity. What are you using? How are you trying to do this? Tell us more, then we can tell you what's wrong and how to fix it.
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.