Showing posts with label achieve. Show all posts
Showing posts with label achieve. Show all posts

Wednesday, March 28, 2012

if else

Hi all,

what is the best possible query to achieve something like this, if these are the columns.

S.no Name Join Date post Sal

1 Abraham 12-03-2007 E.O 2500 $

2 Abrham Null E.O 2500$

3 John Null Trainee 500$

the o/p

S.no Name Join Date post Sal

1 Abraham 12-03-2007 E.O 2500 $

3 John Null Trainee 500$

in short if there is a date value get the latest results, if no date is there get all possible distinct values ?

What you are seeking is not clear.

Easy to understand the part about returning the rows where there is a [Join Date] value.

Not sure what you desire for the non-qualifying rows. (Why is s.no 3 in your results instead of s.no 2?)

|||

This particular thing is what the fourth normal form is all about. If E.O in the different rows actually indicates the same thing, then you really ought to have multiple tables to indicate the Join Date and then the the post and the Salary.

Your schema makes no sense at all. What does a NULL join date mean? Can you explain what the meaning of the first two rows actually are?

I think you are asking if you can have a distinct operation that ignores NULL, and depending on what else your data can do, it might be possible, but can there be three rows? What if two of the rows have distinctly different values, but one has null? If that is the case, you will probably need a cursor to work with your schema....

|||

Sorry if the post wa not clear. Agreed that the schema is in total bad shape, but now we have a requirement wherein we have to select the record which is the latest, base don date and if there is no date then get the other details only.

say like if

A b (date) C

1 today a

1 yestrerday a

1 day bfore sday a

2 Null b

3 NUll b

I have to get the o/p like

1 today a

2 Null b

3 NUll b

Sorry if I had confused in the earlier post. Thanks for the replies...

|||

Would this work for you?

select a, max(b) as b, c
from #x
where b is not null
group by a, c
union
select a, b, c
from #x
where b is null

/Kenneth

Monday, March 19, 2012

Identity reseed error with merge

Are you using automatic range management? If so, the
process of synchronization will reseed if you achieve a
set % of available values. I'd advise against relying on
this behaving correctly in all circumstances and force
the system to never reseed by allocating a huge range to
each subscriber. An integer datatype can span -2billion
to 2billion or so, so there is not really any need to
ever have such a small range that reseeding occurs (IMHO).
HTH,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)
Thanks but these is not the problem. Perhaps I didn't express correctly.
I know the merge replication automatically reseed when it reaches the
imposed limit, but what happened to me is that this seed has returned to
an anterior value, so with the IDs I get concurrence troubles
replicating. The replication and range automatic asignation works
correctly, but I don't know what I did to make the seed backward to a
previous value. The seed didn't reached its limit.
I changed manually the values of the seed in
Distribution.MSrepl_identity_range, but I want to know in what
circurstances those values are being reinitialized to a previous value.
Thanks
Juan
*** Sent via Developersdex http://www.codecomments.com ***
Don't just participate in USENET...get rewarded for it!
|||are they reseeded on the publisher, subscriber or both?
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
"Juan a" <juan@.mailinator.com> wrote in message
news:uNotHeU$EHA.4004@.tk2msftngp13.phx.gbl...
>
> Thanks but these is not the problem. Perhaps I didn't express correctly.
> I know the merge replication automatically reseed when it reaches the
> imposed limit, but what happened to me is that this seed has returned to
> an anterior value, so with the IDs I get concurrence troubles
> replicating. The replication and range automatic asignation works
> correctly, but I don't know what I did to make the seed backward to a
> previous value. The seed didn't reached its limit.
> I changed manually the values of the seed in
> Distribution.MSrepl_identity_range, but I want to know in what
> circurstances those values are being reinitialized to a previous value.
> Thanks
> Juan
> *** Sent via Developersdex http://www.codecomments.com ***
> Don't just participate in USENET...get rewarded for it!
|||They are reinitialized on publisher, but because of automatic range
administration, when the SQLCe synchronize it gets the range asigned
from the publisher, an old range that was used before, and that already
have registers in publisher.
*** Sent via Developersdex http://www.codecomments.com ***
Don't just participate in USENET...get rewarded for it!

Monday, March 12, 2012

Identity problem. (Need generate on subscriber new identity values)

If you change the publication to queued updating, use
automatic identity range management and don't run the
queue reader, you should achieve what you require.
Rgds,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)
But where in that case subcribers updates will be stored? On distributor?
Is it known bug with incorrect handling identity values in replications? Or
it is my own issue?
"Paul Ibison" <Paul.Ibison@.Pygmalion.Com> wrote in message
news:050b01c50853$c6e94010$a601280a@.phx.gbl...
> If you change the publication to queued updating, use
> automatic identity range management and don't run the
> queue reader, you should achieve what you require.
> Rgds,
> Paul Ibison SQL Server MVP, www.replicationanswers.com
> (recommended sql server 2000 replication book:
> http://www.nwsu.com/0974973602p.html)
>
|||The subscriber updates will be held on the queue table at
the subscriber, or you could remove the subscriber
triggers. It is assumed that subscribers are read only in
normal circumstances, so any issues regarding data
changes at a subscriber and problems with identities on
the subscriber are not really catered for. Identities are
only coded for if the subscriber uses immediate updating
or queued updating.
Rgds,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)