Finding Valid Identity Range On Merge Subscriber

Nov 22, 2006

I am using merge replication with automatic identity range management

I want to be able to give a disconnected subscriber a warning message if a certain percentage of the allocated subscriber identity range has been used
- so that they can make sure they reconnect soon to obtain a new identity range

I can get the current identity value OK, but I can't find a good way of finding the current permitted primary and secondary ranges

The information is available in the check constraint, but I don't really want to have to parse this!

CONSTRAINT [repl_identity_range_0DF907AC_40CF_4849_9BD0_2173C90A3805] CHECK NOT FOR REPLICATION (([ContactID]>(10000040000.)
AND [ContactID]<=(10000050000.) OR [ContactID]>(10000050000.) AND [ContactID]<=(10000060000.)))

I can't find any system view which will provide this information

Is there a recommended way of doing this?

Thanks

aero1

View 3 Replies


ADVERTISEMENT

Merge Replication Identity Range Error

Jan 8, 2008

Hi all i have setup merge replication with one publisher and 3 subscribers



The replication worked fine for about 2 months then i recieved the following error on all my subscriptions



The Publisher failed to allocate a new set of identity ranges for the subscription.
This can occur when a Publisher or a republishing Subscriber has run out of identity
ranges to allocate to its own Subscribers or when an identity column data type does
not support an additional identity range allocation. If a republishing Subscriber has
run out of identity ranges, synchronize the republishing Subscriber to obtain more
identity ranges before restarting the synchronization. If a Publisher runs out of identit
(Source: MSSQL_REPL, Error number: MSSQL_REPL-2147199417)
Get help: http://help/MSSQL_REPL-2147199417


I have updated my sql server to service pack 2

The publisher is sql Standard edition and the subscribers are Express edition



Any help would be great

Thanx

View 3 Replies View Related

Can I Set A Default Range For The Identity Values For Merge Replication?

May 8, 2006

Hello,

We have a couple of tables that can have quite a bit of data each day prior to replication. Can we increase the default values for a table for each subscription? For example we have a table called table1 and on the sqlexpress client they could enter in 10000 rows a day, on table2 it's just 100 rows a day. How can we increase the values to where we do not get the error for table1 stating that the insert failed because it conflicted with the identity range check constraint. Thanks in advance.

View 1 Replies View Related

Merge Replication - Setting Identity Range Management.

Feb 2, 2007

Hi All;

I am trying to set up Merge Replication on a database and want to set the IdentityRange Management to Auto for all my tables which use a Identity column.

In the wizard, on Article Properties Page, I can do this by selecting a Table, and going for its properties, but this is a tedious task as I have ~300 tables to set this property on.

Is there another way or a global location where I can set the property to true and even mention the ranges and the threshold, so that I dont have to pick each table and set it individually.

I am also aware of the fact that I can Generate a Script and modify it and run that, but I was looking for some way to do this in the wizard.

Thanks!

View 1 Replies View Related

Weird Results Post Merge Agent Run (Automatic Identity Range Management)

Dec 1, 2005

I have implemented replication between 2 servers (SERVER1 AND SERVER2) and for test purposes i just have 1 table(Table1) in the publisher.

View 1 Replies View Related

Change A Merge Subscriber To Become A Merge Publisher

Aug 16, 2004

Hi,

I'm using merge replication to maintain a backup copy of my main (publisher)MSDE database. A push subscription periodically (1 per minute) updates the backup DB.
It's intended that if the main db goes down then the backup (subscription) db can be configured as a publisher. This must all be performed via scripting.
The initial configuration of the main publisher and subscription is controlled via scripting, which works fine.
The problems occur when I try to configure the subsciber to become a publisher. A script is executed on the subscriber but fails at the point when it's configuring the publisher detail. The error is something like "unable to configure a publication for a database setup as an anonymous subscription".
I'm guessing that there are subscritpion artifacts added to the database which need to be removed before it can be configured as a new publisher.

Please help,
Jez W

View 1 Replies View Related

Finding Skipped Transactions At The Subscriber.

Dec 7, 2006

We've set up transactional replication to continue on data consistency errors and we do see in the replication monitor that records are skipped at the subscriber. Our subscriber is SQL2K and our publisher is SQL2K5. How can we see the records that were skipped and why they were skipped.

View 4 Replies View Related

Finding Non Valid Dates With A Char Field

Aug 9, 2007

I have a table with several million rows of data. There is a date field defined as a char(8) with some bad rows. i tried to locate them with below

select date_stopped from patient_medication
where isdate(convert(datetime,date_stopped)) = 1

This won't work, I get the
Server: Msg 242, Level 16, State 3, Line 1
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value

Any way around this?

View 2 Replies View Related

Return Last Valid Record When Query Is Outside The Range?

Dec 18, 2012

Using MSSQL 2008 R2

Given the following table

Code:
{ID, PropClass, OffSet, Amount}
{1, 1, 1, .30}
{2, 1, 2, .45}
{3, 1, 3, .50}
{4, 2, 1, .26}
{5, 2, 2, .15}

If I know the exact offset I can query easily enough using PropClass and the exact offset. But what if the offset is not included in the range for a given PropClass? How can I get a query to return the last valid record for a given PropClass from within a join?

For example, if my query contained PropClass = 1 and offset = 4, it should return the Amount of .50 from Record with ID 3

This is a query that I am trying to work on:

Code:
SELECT v.District, v.PropClass, YearAquired, SUM(cost * cnt), SUM(v.Cost * v.Cnt * t.Amount), SUM(v.Tax), COUNT(*)
FROM UPValue v
INNER JOIN UPMaster m on m.Year = v.year and m.Account = v.account
INNER JOIN UPTable T on t.PropClass = v.PropClass and t.Offset = v.Year - v.YearAquired
WHERE v.Year = 2012 and LeaseType = 2
group by v.District, v.PropClass, YearAquired
order by v.District, v.PropClass

Using <= will not work because that would return multiple records from UPTable when the offset is < the max offset.

View 4 Replies View Related

Get Records That Have Valid Date Range For Today

Aug 19, 2013

I want to get all records that have a valid date range for todays date(20130819).

All records have a date_f and date_t. I need to check that against todays date. The below code is my version of sql pseudo code.

SELECT DISTINCT
p.id,
p.name,
c.ip_number
FROM
tbl_Person AS p, tbl_current_conn_ipnumber AS c

[Code] .....

View 2 Replies View Related

Replication :: Not Create New Constraint Range For Subscriber

Jul 14, 2015

I have a merge replication in place.  I increased the identity_range to 100000 for a table.  I have done this both ways, via the properties of the publication on SSMS, and via TSQL.  I have call sp_adjustpublisheridentityrange.  Then I recreated the sanpshot.  EXEC sp_adjustpublisheridentityrange @table_name = N'Label', @table_owner = N'caseup';but after synchronization, the range defined in the table's constraint has not changed and now all of the identity values are used up.  All inserts are failing.What needs to be done to force the publisher to recreate the identity range on a subscriber(s).

View 3 Replies View Related

Specified Argument Was Out Of The Range Of Valid Values. Parameter Name: Index

May 21, 2007

This is the error I'm getting. I will paste my code below:









"
DeleteCommand="DELETE FROM [Friends] WHERE [FriendName] = @FriendName"
SelectCommand="SELECT * FROM [Friends] WHERE (([FriendName] = @FriendName))"
UpdateCommand="UPDATE [Friends] SET [UserName] = @UserName, [UserID] = @UserID, [IP] = @IP, [AddedOn] = @AddedOn, [FriendName] = @FriendName, [IsApproved] = @IsApproved WHERE [FriendID] = @FriendID">














Type="String" />



DataSourceID="request_source" DefaultMode="Edit" EmptyDataText="You have no pending friend requests"
GridLines="None" Height="50px" Width="125px">




ReadOnly="True" SortExpression="UserName" />



Text="Accept" /> 
CommandName="Delete" Text="Deny" />



Text="Edit" /> 
CommandName="Delete" Text="Delete" />



ReadOnly="True" SortExpression="FriendID" Visible="False" />









'>


'>

View 10 Replies View Related

Merge Replication Subscriber

Sep 6, 2001

SQL Server 7.0 SP3

I am using the "Pull Subscription Wizard" to set up merge replication. I go through all the steps of the wizard and then I hit "Finish" at the end. When it gets to the third step (Creating the Subscription), I get the old:

__________________________________________________ _________
mmc.exe has generated errors and will by closed by Windows.
You will need to restart the program.

An error log is being created.
__________________________________________________ _________

This happens whether I try to do this from my PC or from the actual server I am creating the subscription on.

Has anyone else had this issue? Is there a hotfix I need?

Any help is appreciated.

Thanks,
Craig

View 1 Replies View Related

Push Subscriber In Merge Replication

Jul 26, 2004

I am using merge replication with a push subscription type. I am wondering if the updates of the tables on the subscriber side are push to the publisher from the subscriber or pulled from the subscriber by the publisher when the syncronisation takes place. this makes a big diferrence for me and i can't find the answer to this question anywhere...

if anyone could answer it would be really appreciated

Thanks

View 3 Replies View Related

Merge Replication With Read-only Subscriber

Nov 17, 2007

Using SQL CE 3.1 merge replication. Working fine, but want to make subscription read only. In other words, master/slave pattern.
How is this accomplished?

View 3 Replies View Related

The Merge Process Could Not Enumerate Changes At The 'Subscriber'.

Apr 19, 2006

I have two SQL 2005 Standard servers using merge replication, and out of the blue started getting failure notices regarding "The merge process could not enumerate changes at the 'Subscriber'." I turned on verbose logging and noticed the following section:

2006-04-19 12:53:33.227 Category:NULL
Source: Merge Replication Provider
Number: -2147200999
Message: The merge process could not enumerate changes at the 'Subscriber'. When troubleshooting, restart the synchronization with verbose history logging and specify an output file to which to write.
2006-04-19 12:53:33.227 The Merge Agent was unable to update information about the last synchronization at the Subscriber. Ensure that the subscription exists at the Subscriber, and restart the Merge Agent.
2006-04-19 12:53:33.227 The merge process was unable to update last synchronization information at the Publisher.


Using Profiler on both sides, I don't see anything out the ordinary during the replication process until there are two calls in a row to the stored procedure sp_MSadd_merge_history90, where the second one is storing the error message listed above.

Any ideas?

Thanks,

Scott Davis

View 8 Replies View Related

Merge Replication Subscriber Status

Sep 22, 2007



Hi.
I have setup an SQL Server 2005 Merge Replication.
Now I need to display the status of the replication programatically from the subscriber side, I have checked the documentation which mentions MergeSubscription & MergeSubscriberMonitor but I couldn't know how to use them!!
Any Help ?
Thanks

View 3 Replies View Related

Deletes On Subscriber In Merge Replication

Oct 20, 2006

Using Merge replication between SQL Server 2000 and SQL Server CE,
is there any way that row deletes could occur on the subscriber without a reinitialize
or explicit delete of row on publisher.

More specifically, if there is a row filter that returns a days worth of data with each
days pull, for example, and the filter looked like
select <columns> from Table where UpdateDate < GETDATE() and UpdateDate >= DATEADD(d,1,GETDATE())
would there be some implicit delete at subscriber each day because data sent changed?

My research indicates this does not happen, but I have a colleague who thinks differently.

View 5 Replies View Related

Merge Replication - Subscriber Error

Apr 20, 2007

Hi,

I have setup merge replication between SQL Server 2005 and SQL Server Express. The setup uses web synchronization. (And the setup uses dynamic filter HOST_NAME)

On some of the client machines, replication fails with the following error (when initializing the subscription):

from subscriber merge agent verbose log:
A dynamic snapshot will be applied from 'D:DOCUME~1JBAUMG~1.CORLOCALS~1TempDB101-EQA-SCL_BQDB_BQ_PUB_BQDB'

Validating dynamic snapshot
2007-04-1819:39:45.434 OLE DB Subscriber 'FRG-BAUMGARTENJSQLEXPRESS': sys.sp_MSregisterdynsnapseqno @snapshot_session_token=N'\XXX.XX.XX.XXSnapshotuncDB101-EQA-SCL_BQDB_BQ_PUB20070417180079dynsnap', @dynsnapseqno='5599F67E-A1A9-4573-A14F-9851F6FE4B51'

(Note: XXX.XX.XX.XX is a proper IP of DB, I have just masked it in the post)

The merge process was unable to deliver the snapshot to the Subscriber. If using Web synchronization, the merge process may have been unable to create or write to the message file.When troubleshooting, restart the synchronization with verbose history logging and specify an output file to which to write.

I enabled verbose logging for the snapshot agent for the subscriber, but there was no error there. It is obvious from the log info above that the error occurs only after downloading the snapshot to the client and during applying it to the subscriber by the merge agent.

After I got this error, I tried running the subscriber program again and it successfully replicated on the third attempt. But this behavior is not consistent and it fails for most of the time on some of the machines

Any info on this error?

View 6 Replies View Related

Merge Process Could Not Enumerate Changes At The Subscriber

Apr 27, 2007

Hi,



I've seen quite a few posts about this error message but so far no answers. I'm merge replicating between SQL Server 2005 SP2 and SQL Server 2005 Mobile. Everything seems to run really well until at some point I get the above error message while running the replication from the device. It seems to happen just after I've made a schema change on the server e.g. the latest one was adding some new columns (which allow nulls) to replicated tables.



I've switched on verbose logging and I get the following:



2007/04/27 13:57:06 Hr=00000000 Compression Level set to 1
2007/04/27 13:57:06 Hr=00000000 Count of active RSCBs = 0
2007/04/27 13:57:06 Thread=B04 RSCB=15 Command=OPWC Hr=00000000 Total Compressed bytes in = 846
2007/04/27 13:57:06 Thread=B04 RSCB=15 Command=OPWC Hr=00000000 Total Uncompressed bytes in = 1442
2007/04/27 13:57:06 Thread=B04 RSCB=15 Command=OPWC Hr=00000000 Responding to OpenWrite, total bytes = 846
2007/04/27 13:57:06 Thread=B04 RSCB=15 Command=OPWC Hr=00000000 C:Program FilesMicrosoft SQL Server 2005 Mobile Editionserverctmobilesql30.7AABD0FB7460_010309C7-9030-4CF9-7D60-A64608CD62F7 0
2007/04/27 13:57:06 Thread=E54 RSCB=15 Command=SYNC Hr=00000000 Synchronize prepped 0
<PARAMS RSCB="15" HostName="" Publisher="WINSERVER" PublisherNetwork="" PublisherAddress="" PublisherSecurityMode="1" PublisherLogin="" PublisherDatabase="CompacTimesheet_Staging" Publication="CompacTimesheet_Staging" ProfileName="DEFAULT" SubscriberServer="CTimeMobile - 7aabd0fb7460" SubscriberDatabasePath="Program FilesCompac TimesheetDataCompacTimesheetMobile.sdf" Distributor="WINSERVER" DistributorNetwork="" DistributorAddress="" DistributorSecurityMode="1" DistributorLogin="" ExchangeType="3" ValidationType="0" QueryTimeout="300" LoginTimeout="15" SnapshotTransferType="0" DistributorSessionId="452"/>
2007/04/27 13:57:06 Thread=E54 RSCB=15 Command=SYNC Hr=80045019 The merge process could not enumerate changes at the 'Subscriber'. When troubleshooting, restart the synchronization with verbose history logging and specify an output file to which to write. -2147200999
2007/04/27 13:57:06 Thread=E54 RSCB=15 Command=SYNC Hr=80045645 The process was successfully stopped. -2147199419
2007/04/27 13:57:06 Thread=E54 RSCB=15 Command=SCHK Hr=80004005 SyncCheck responding 0
2007/04/27 13:57:06 Thread=E54 RSCB=15 Command=SCHK Hr=00000000 Removing this RSCB 0



The error message doesn't seem very helpful. Is there another way to find out what is causing the problem? I've tried reinitializing all subscriptions and generating a new snapshot but it makes no difference. The only way I've found to fix this is to delete the database on the subscriber and synchronise again (losing all subscriber data since the last sync).



Regards,



Greg

View 3 Replies View Related

Merge Join: The Clolumn With The SortKeyPosition Value Of 0 Is Not Valid. It Should Be 4.

Apr 15, 2008

Hi,

I have a Data flow task with two OLE DB sources, which are both sorted by same columns (order by) and IsSorted, sortKeyPosition are both set.

Then I have a Merge join (left join) where I get validation error: The clolumn with the SortKeyPosition value of 0 is not valid. It should be 4.
However this only happens if I include a join key column also as output.
Can columns be both join keys and output?

Thanks, Janez

View 11 Replies View Related

Manage Identity Field At Subscriber

Aug 3, 2007

Anyone has the standard approach for handling the identity column with replication environment.
Currently i am using following process.

http://www.databasejournal.com/features/mssql/article.php/3483421

I want to know if someone have some generic script to do this or much easier way..

View 2 Replies View Related

Merge: Records Associated By A JOIN Filter Not Being Sent To A Subscriber

Jan 25, 2007

Hi,

I have a merge (SQL 2005 Standard -> Express) topolgoy which is having problems 

The main problem is that the join filters don't seem to work for one area and I am hoping someone can help me with some troubleshooting advice

There are 140+ tables in the topology but the ones causing  particular  pain are a parent child relationship where the child is actually a bridge/linking table to another table.

Therefore although it is a parent child in the replication filters it is the reverse. i.e. the child has the paramterised filter on it and the parent is one level down joined by it's id.  There are other tables joined to this parent table but it stays at three levels deep.  The @join_unique_key therefore is set to 0 as is the partition options for the parent /child relationship.

However, when we synchronise we have a problem. The rows get inserted in to the database in RI order but only the child records are replicated down to the subscriber.

The child table with the parameterised filter has 13 articles joined to it in total and one of the other branches of join filters go down as deep as four levels.  Most though do not.

Does anyone have any suggestions as to why this might be happening?  Any help would be greatly appreciated.

Cheers, James

P.S. I should add this problem only occurs when the edits are made at the publisher.  If new records are added at the subscriber everything is fine.

View 9 Replies View Related

Merge Replication, Subscriber Can Only Download But Not Upload??

Apr 28, 2007

Hi,

I need a urgent help! The problem is that every synchronization only transfer data from subscriber to publisher, but not the other direction. The publisher is sql server 2005 standard edition, and the subscriber is 2005 express. Is that any stored-procedure to deal with such a problem?

Thanks for any commnet.

View 14 Replies View Related

Monitoring Merge Push Subscription From Subscriber

Jul 3, 2007

Hi all!

Is there an option to monitor current state of Merge Push Subscription from the Subscriber, without connecting to the Publisher Server? I have examined many SPs and system tables at Subscriber, but didn't find any reliable method...

View 4 Replies View Related

Replication :: Merge Data Cannot Sync To Subscriber

Jun 29, 2015

I have the merge replication (Push)  for SQL Server 2008.The right-click option for Start and Stop Synchronizing in subscriptions has been disabled. How can I stop the merge replication and start again ?

This error happened 1 week after I created the merge replication. The merge data cannot sync to subscriber and only solution I can use is drop and re-create the merge replication again but error would be re-occur a week later. The merge replication work fine before and start from middle on May 2015, but it keep happen right now.

View 8 Replies View Related

Table Name Is Not Valid Sqlceexception During Merge Replication Initialization

Apr 21, 2008

During merge replication initialization from SQL Server 2005 to SQL Server CE 3.5 on Windows Mobile 5.0

I am getting the following errors:




On Device
{"The table name is not valid. [ Token line number (if known) = 1,Token line offset (if known) = 21,Table name = COLLECTION ]"}
base {System.SystemException}: {"The table name is not valid. [ Token line number (if known) = 1,Token line offset (if known) = 21,Table name = COLLECTION ]"}
HResult: -2147217900
Message: "The table name is not valid. [ Token line number (if known) = 1,Token line offset (if known) = 21,Table name = COLLECTION ]"
NativeError: 26100
Source: "Microsoft SQL Server Compact"

{System.Data.SqlServerCe.SqlCeError: The SQL statement failed to execute. If this occurred while using merge replication, this is an internal error. If this occurred while using RDA, then the SQL statement is invalid either on the PULL statement or on the SubmitSQL statement. [ SQL statement = ALTER TABLE [dbo].[COLLECTION] ADD CONSTRAINT [PK_COLLECTION] PRIMARY KEY CLUSTERED ( [SERIAL_NUMBER], [STORE_CODE], [COLLECT_DATE] )WITH PAD_INDEX , FILLFACTOR = 90 ]}
Source: "Microsoft SQL Server Compact"








Server Logged:
...
2008/04/20 20:03:16 Thread=EA0 RSCB=5 Command=SCHK Hr=00000000 SyncCheck responding 0
2008/04/20 20:03:17 Thread=B90 RSCB=5 Command=OPNR Hr=00000000 End Of Data Set 1
2008/04/20 20:03:17 Thread=B90 RSCB=5 Command=OPNR Hr=00000000 Responding to Fetch, bytes = 50259
2008/04/20 20:03:17 Thread=970 RSCB=5 Command=CLOS Hr=00000000 Total Compressed bytes out = 50259
2008/04/20 20:03:17 Thread=970 RSCB=5 Command=CLOS Hr=00000000 Total Uncompressed bytes out = 390254
2008/04/20 20:03:17 Thread=970 RSCB=5 Command=CLOS Hr=00000000 Removing this RSCB 0
2008/04/20 20:03:19 Hr=00000000 Compression Level set to 1
2008/04/20 20:03:19 Hr=80004005 ACK:Error for DistributorSessionID = 80
2008/04/20 20:03:19 Hr=80004005 The SQL statement failed to execute. If this occurred while using merge replication, this is an internal error. If this occurred while using RDA, then the SQL statement is invalid either on the PULL statement or on the SubmitSQL statement. [,,,SQL stateme 28560









The same tables in a different on a different SQL box (test) replicate fine, but on this box (production) they do not. Any idea what would be the difference in the two environments?

I suspect that the "dbo." part in the "alter table" is what it is messing up on... how can I tell SQL CE not to include that schema prefix?
Thanks

View 12 Replies View Related

Finding Last Saturday Date Then Range Last 28 Days

Jul 18, 2014

In my query I have a date field and using that date field I want to pass the date to a function, or whatever is most appropriate, then compare that date with a range of the last 4 weeks, which will be numbered 1-4, 1 being earliest and 4 being latest, and then return the week number.

I've determined I need some sort of look up but will need to be dynamic - thinking maybe a temp table, first using the date the report is run on and counting 28 days back from the most recent last saturday then setting number to 1 for first 7 days then 2 for next 7 days etc.

View 8 Replies View Related

SQL Server 2008 :: Merge Replication - Replacing A Subscriber

Mar 4, 2015

We have a central office with a SQL2005SP4 server (yeah, I know... old as heck) that's the main database and it has multiple subscribers in regional offices. Well... one of the regional offices server is failing, and it needs to be replace.

The original server is an ancient Win2003 86x

The Server team will build a new Win2008r2 64x, and use the same name and IP address

And I'm tasked with the SQL part.

I'll be installing the same version/patch of SQL, but 64x instead, and migrate all databases, including the system databases.

How do I handle replication? Do I need to reintialize from scratch? or can I just use the backup as a starting point?

View 1 Replies View Related

Merge Replication: Missing Rows At Subscriber With No Conflicts

Jul 18, 2007

Hi all,



We are using a mix of SQL 2005 and 2000 servers and our "main" database server is running SQL 2005 x64 (SP2 ver. 3042).



Our system has run perfectly for months, then subsequent to an SP2 update we are seeing several instances where the data record counts are different for several tables among all the servers.



We are using Merge Replication, with no filters and published every 2 minutes.



Any ideas?



TIA,

Michael

View 1 Replies View Related

How To Speedup Data From Subscriber To Publisher On Merge Replication?

Mar 9, 2007

How to speedup data from subscriber to Publisher on Merge replication?

Is there any we can speed up data from Subscriber to Publisher (uploading).

Subscriber downloading data from publisher running more than 20 hours after drop and recreate subscriber.

Could you please post reply.

Regards
Ponnu

View 2 Replies View Related

Finding Highest Current Number Only For Increasing Range

Jan 26, 2012

RecordNo Speed
-------- -----
1 0
2 0
3 0
4 0
5 23
6 66
7 48
8 0
9 31
10 0
11 34
12 23

The above data shows the speed of vehicle over a time period, given the above data I need to achieve the result below:

RecordNo Speed LastAcceleration
-------- ----- ----------------
1 0 0
2 0 0
3 0 0
4 0 0
5 23 23
6 66 66
7 48 66
8 0 66
9 31 31
10 0 31
11 34 34
12 23 34

The code below is almost there but falls over on Recordno 8:

select
curr.recordno,curr.speed
,CASE WHEN curr.speed >= ISNULL(prev.speed,0) THEN curr.speed
ELSE (
SELECT MAX(speed) FROM speedtest
WHERE recordno between (CASE WHEN curr.speed >= prev.speed then curr.recordindex else prev.recordno end ) and curr.recordno

[code]...

View 4 Replies View Related

Finding If Any Part Of Date Range Falls In Period?

Jan 3, 2014

I'm trying to find if any part of a date range in my table between orig_start_rent and stop_rent falls within a period I specify in two variables: startPeriod and endPeriod

For example if I specify 2013-11-01 as startPeriod and 2013-11-30 as endPeriod, then if any part of the date range between orig_start_rent and stop_rent(stop-rent can be null if hire is open) falls within that period, I want that to be picked up and assigned the value of 1 in my case statement for OnHire. My code is not picking everything up however - using the example above, a record with orig_start_rent of 2013-05-23 and stop_rent of 2013-11-18 is being assigned 0 when it should be 1. My code here:

declare @startPeriod as smalldatetime
declare @endPeriod as smalldatetime
set @startPeriod = '2013-11-01'
set @endPeriod = '2013-11-30';
select dticket, orig_start_rent, stop_rent, case when orig_start_rent >= @startPeriod and orig_start_rent <= @endPeriod then 1 when orig_start_rent < @endPeriod and stop_rent is null then 1 else 0 end [OnHire] from deltickitem

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved