Showing posts with label assume. Show all posts
Showing posts with label assume. Show all posts

Saturday, February 25, 2012

Delete Table Row if row is blank

Hi All,

I face one problem.

I have one table in .rdlc to display all the sales in that table, but some of the sales is blank and assume there are only two column in table.

So when detect the row for that two column is blank, either the table will skip listing out the blank data or delete that particular row.

How can i do it?

By the way, assume the data we get from database can not filter the blank value.

Thanks

Kendy

In the table layout, you can set the Visible of a row by using the Expression.

=IIF(IsNothing(Column1) AND IsNothing(Column2), False, True)

HTH

|||

Hello Kendy,

Right click on your detail row and go to Properties. Expand Visibility, then enter this in the Hidden property:

=IIf(IsNothing(Fields!Field_1.Value) and IsNothing(Fields!Field_2.Value), True, False)

Remember, this is the hidden property so if they are both empty, you want the hidden property to be set to True.

Hope this helps.

Jarret

|||

Hi Jarret,

Its help and works, thanks.

Kendy

Tuesday, February 14, 2012

Delete older entries with duplicate names

Assume I have the following table.

id name
-- ----
1 John
2 Josh
3 Mike
4 John
5 Dana
6 Josh
7 John

I want to delete the older entries of the duplicate names. So in this instance, I want to delete id 1, 2 and 4.

Thanks ahead of time...drop table table1
go
create table table1(id int
,iname varchar(10))
go
insert table1 select 1,'John'
insert table1 select 2,'John'
insert table1 select 3,'Mike'
insert table1 select 4,'John'
insert table1 select 5,'Dana'
insert table1 select 6,'Josh'
insert table1 select 7,'John'
go
select *
--delete
from table1
where iname in (select iname from table1 group by iname having count(*)>1)
and id not in (select max(id) from table1 group by iname having count(*)>1)|||Is there not a way to do it programmatically without defining which names to re-insert? I have a few hundred rows of duplicates|||Originally posted by jiggle it
Is there not a way to do it programmatically without defining which names to re-insert? I have a few hundred rows of duplicates
What do you mean "to re-insert"? Just run last query and all older reconds for duplicates will be gone. ;)|||I found the answer

http://aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=186|||DELETE Table1
WHERE id IN
(SELECT A.id from Table1 A, Table1 B
WHERE A.name = B.name
AND A.id < B.id)

May not be as efficient but requires less typing, which is a plus in my book )