Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Linked Server Nolock Getdate issue

Author  Topic 

senthilaa
Starting Member

12 Posts

Posted - 2008-04-14 : 02:47:25
Hi,

I am trying to retreive data using selet into query with nolock. Select query selects around 50,000 records from a linked server and inserting into my database. I have getdate() in my select list and it is returning different datetime in a single query which leads to a problem while taking distinct in later stages. Any info on why this nolock returns different datetime in a single getdate() statement will be a gr8 help.

Thanks in advance,
Senthil

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2008-04-14 : 03:54:59
Can you assign GETDATE() to a local variable first and then put the variable in the select?

--
Lumbago
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-04-14 : 03:55:39
What RDBMS is the source?



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

eralper
Yak Posting Veteran

66 Posts

Posted - 2008-05-13 : 01:14:01
Hello,

As far as I know you can not use (NoLock) hint on a SELECT statement over a Linked Server Table.

And one more note if you are selecting current datetime using GETDATE(), it is the time stamp on the local server not the time on the linked server.

Eralper
http://www.kodyaz.com/content/SQLServerArticles.aspx



-------------
Eralper
http://www.kodyaz.com
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-05-13 : 01:20:48
quote:
Originally posted by senthilaa

Hi,

I am trying to retreive data using selet into query with nolock. Select query selects around 50,000 records from a linked server and inserting into my database. I have getdate() in my select list and it is returning different datetime in a single query which leads to a problem while taking distinct in later stages. Any info on why this nolock returns different datetime in a single getdate() statement will be a gr8 help.

Thanks in advance,
Senthil


You could strip off the time part while storing the date values if you really dont require them in your calculations.You can use
DATEADD(dd,DATEDIFF(dd,0,GETDATE()),0) so that all date values will contain only date part with time part cleared to 00:00:00.000
Go to Top of Page
   

- Advertisement -