You are here: cursor to compare/report on the same fields in 2 tables « MsSQL Server « IT news, forums, messages
cursor to compare/report on the same fields in 2 tables

Posted by SQLNewbie on 09/20/06 19:00

I have the following cursor that I am comparing 2 tables, the
production table and a copy of the production table, I want results of
all address's that are like the address1 field...the problem is...my
results are giving me every field and if there is more than one, it is
putting it in a grid....

I only want to see results if they are > 1 for the same address field

this is what I have so far....


declare @address1 char(61),@city char(61)

declare address_cursor CURSOR FOR
SELECT address1,city FROM test.dbo.testadd

OPEN address_cursor

fetch next from address_cursor into @address1,@city
while @@fetch_status = 0
BEGIN
select * from testadd where @address1 like '%' + address1 + '%' and
@city = city
Fetch next from address_cursor into @address1,@city
Print
END
CLOSE address_cursor
DEallocate address_cursor

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация