Showing posts with label bit. Show all posts
Showing posts with label bit. Show all posts

Thursday, March 29, 2012

Filter by uniqueidentifier in DPW's don't work, and yet sometimes do?

According to Microsoft, when executing a query against a linked server, any
filtering (where condition) against a uniqueidentifier or bit columns cannot
be applied on the remote server. Instead, all rows in the remote server's
table will be brought across the wire, and the filter condition will be
applied locally.
This can be demonstrated by declaring a view
CREATE VIEW ActionItems AS SELECT * FROM
RemoteServer.dbo.Database.ActionItems
that queries the table
CREATE TABLE [ActionItems1] (
[ActionItemID] [uniqueidentifier] NOT NULL CONSTRAINT
[DF_ActionItems1_ActionItemID] DEFAULT (newid()),
[AssociatedEmployeeID] [uniqueidentifier] NULL ,
[AssociatedActionItemID] [uniqueidentifier] NOT NULL , --clustered
[ParentActionItemID] [uniqueidentifier] NULL ,
CONSTRAINT [PK_ActionItems1_1] PRIMARY KEY NONCLUSTERED
(
[ActionItemID]
)
)
Now, i will try to filter by a uniqueidentifier:
SELECT ActionItemID FROM ActionItems
WHERE ActionItemID = '28E5D33A-8946-48A6-BEFC-A0C07914D440'
StmtText
------
|--Filter(WHERE[Jango].[CasinoHR].[dbo].[ActionItems1].[ActionItemID]=28E5D33A-8946-48A6-BEFC-A0C07914D440))
|--Remote Query(SOURCEJango), QUERYSELECT Tbl1001."ActionItemID"
Col1003 FROM "CasinoHR"."dbo"."ActionItems1" Tbl1001))
And as expected and documented, all rows are returned, then a filter is
applied to get the one row.
But wait! Now i will try to filter by a uniqueidentifier:
SELECT ActionItemID FROM ActionItems
WHERE AssociatedEmployeeID = '4C5CD857-8DD4-4279-B017-7CF1C49B23D9'
StmtText
--------
|--Remote Query(SOURCEJango), QUERYSELECT Tbl1001."ActionItemID"
Col1004 FROM "CasinoHR"."dbo"."ActionItems1" Tbl1001 WHERE
Tbl1001."AssociatedEmployeeID"=?))
And not as expected, and opposite as documented, only the matching rows are
returned - and the filter is applied on the remote server.
But wait! Now i will try to filter by a uniqueidentifer:
SELECT ActionItemID FROM ActionItems
WHERE AssociatedEmployeeID is not null
StmtText
-------
|--Filter(WHERE[Jango].[CasinoHR].[dbo].[ActionItems1].[AssociatedEmployeeID]<>NULL))
|--Remote Query(SOURCEJango), QUERYSELECT
Tbl1001."AssociatedEmployeeID" Col1005,Tbl1001."ActionItemID" Col1003 FROM
"CasinoHR"."dbo"."ActionItems1" Tbl1001))
And as expected and documented, all rows are returned, then a filter is
applied to get the one row.
But wait! Now i will try to filter by a uniqueidentifier:
SELECT ActionItemID FROM ActionItems
WHERE AssociatedActionItemID = 'C8A32A8F-2AF8-4B4A-9954-27274F4F6B01'
StmtText
-------
|--Remote Query(SOURCEJango), QUERYSELECT Tbl1001."ActionItemID"
Col1004 FROM "CasinoHR"."dbo"."ActionItems1" Tbl1001 WHERE
Tbl1001."AssociatedActionItemID"=?))
And not as expected, and opposite as documented, only the matching rows are
returned - and the filter is applied on the remote server.
So what's up? Either SQL Server can pass a filter condition on a
uniqueidentifier field to the remote server, or it cannot. Which is it? The
documentation says it cannot. The documentation does not say that it cannot
except for sometimes - who's logic isn't apparent or logical.
Oops, DPW should be DPV
Distributed Partitioned Views
sql

Filter by uniqueidentifier in DPW's don't work, and yet sometimes do?

According to Microsoft, when executing a query against a linked server, any
filtering (where condition) against a uniqueidentifier or bit columns cannot
be applied on the remote server. Instead, all rows in the remote server's
table will be brought across the wire, and the filter condition will be
applied locally.
This can be demonstrated by declaring a view
CREATE VIEW ActionItems AS SELECT * FROM
RemoteServer.dbo.Database.ActionItems
that queries the table
CREATE TABLE [ActionItems1] (
[ActionItemID] [uniqueidentifier] NOT NULL CONSTRAINT
[DF_ActionItems1_ActionItemID] DEFAULT (newid()),
[AssociatedEmployeeID] [uniqueidentifier] NULL ,
[AssociatedActionItemID] [uniqueidentifier] NOT NULL , --clustered
[ParentActionItemID] [uniqueidentifier] NULL ,
CONSTRAINT [PK_ActionItems1_1] PRIMARY KEY NONCLUSTERED
(
[ActionItemID]
)
)
Now, i will try to filter by a uniqueidentifier:
SELECT ActionItemID FROM ActionItems
WHERE ActionItemID = '28E5D33A-8946-48A6-BEFC-A0C07914D440'
StmtText
----
----
|--Filter(WHERE[Jango].[CasinoHR].[dbo].[ActionItems1].
1;ActionItemID]=28E5D33A-8946-48A6-BEFC-A0C07914D440))
|--Remote Query(SOURCEJango), QUERYSELECT Tbl1001."ActionItemID"
Col1003 FROM "CasinoHR"."dbo"."ActionItems1" Tbl1001))
And as expected and documented, all rows are returned, then a filter is
applied to get the one row.
But wait! Now i will try to filter by a uniqueidentifier:
SELECT ActionItemID FROM ActionItems
WHERE AssociatedEmployeeID = '4C5CD857-8DD4-4279-B017-7CF1C49B23D9'
StmtText
----
----
--
|--Remote Query(SOURCEJango), QUERYSELECT Tbl1001."ActionItemID"
Col1004 FROM "CasinoHR"."dbo"."ActionItems1" Tbl1001 WHERE
Tbl1001."AssociatedEmployeeID"=?))
And not as expected, and opposite as documented, only the matching rows are
returned - and the filter is applied on the remote server.
But wait! Now i will try to filter by a uniqueidentifer:
SELECT ActionItemID FROM ActionItems
WHERE AssociatedEmployeeID is not null
StmtText
----
----
--
|--Filter(WHERE[Jango].[CasinoHR].[dbo].[ActionItems1].
1;AssociatedEmployeeID]<>NULL))
|--Remote Query(SOURCEJango), QUERYSELECT
Tbl1001."AssociatedEmployeeID" Col1005,Tbl1001."ActionItemID" Col1003 FROM
"CasinoHR"."dbo"."ActionItems1" Tbl1001))
And as expected and documented, all rows are returned, then a filter is
applied to get the one row.
But wait! Now i will try to filter by a uniqueidentifier:
SELECT ActionItemID FROM ActionItems
WHERE AssociatedActionItemID = 'C8A32A8F-2AF8-4B4A-9954-27274F4F6B01'
StmtText
----
----
--
|--Remote Query(SOURCEJango), QUERYSELECT Tbl1001."ActionItemID"
Col1004 FROM "CasinoHR"."dbo"."ActionItems1" Tbl1001 WHERE
Tbl1001."AssociatedActionItemID"=?))
And not as expected, and opposite as documented, only the matching rows are
returned - and the filter is applied on the remote server.
So what's up? Either SQL Server can pass a filter condition on a
uniqueidentifier field to the remote server, or it cannot. Which is it? The
documentation says it cannot. The documentation does not say that it cannot
except for sometimes - who's logic isn't apparent or logical.Oops, DPW should be DPV
Distributed Partitioned Views

Filter by uniqueidentifier in DPW's don't work, and yet sometimes do?

According to Microsoft, when executing a query against a linked server, any
filtering (where condition) against a uniqueidentifier or bit columns cannot
be applied on the remote server. Instead, all rows in the remote server's
table will be brought across the wire, and the filter condition will be
applied locally.
This can be demonstrated by declaring a view
CREATE VIEW ActionItems AS SELECT * FROM
RemoteServer.dbo.Database.ActionItems
that queries the table
CREATE TABLE [ActionItems1] (
[ActionItemID] [uniqueidentifier] NOT NULL CONSTRAINT
[DF_ActionItems1_ActionItemID] DEFAULT (newid()),
[AssociatedEmployeeID] [uniqueidentifier] NULL ,
[AssociatedActionItemID] [uniqueidentifier] NOT NULL , --clustered
[ParentActionItemID] [uniqueidentifier] NULL ,
CONSTRAINT [PK_ActionItems1_1] PRIMARY KEY NONCLUSTERED
(
[ActionItemID]
)
)
Now, i will try to filter by a uniqueidentifier:
SELECT ActionItemID FROM ActionItems
WHERE ActionItemID = '28E5D33A-8946-48A6-BEFC-A0C07914D440'
StmtText
------
|--Filter(WHERE:([Jango].[CasinoHR].[dbo].[ActionItems1].[ActionItemID]=28E5D33A-8946-48A6-BEFC-A0C07914D440))
|--Remote Query(SOURCE:(Jango), QUERY:(SELECT Tbl1001."ActionItemID"
Col1003 FROM "CasinoHR"."dbo"."ActionItems1" Tbl1001))
And as expected and documented, all rows are returned, then a filter is
applied to get the one row.
But wait! Now i will try to filter by a uniqueidentifier:
SELECT ActionItemID FROM ActionItems
WHERE AssociatedEmployeeID = '4C5CD857-8DD4-4279-B017-7CF1C49B23D9'
StmtText
--------
|--Remote Query(SOURCE:(Jango), QUERY:(SELECT Tbl1001."ActionItemID"
Col1004 FROM "CasinoHR"."dbo"."ActionItems1" Tbl1001 WHERE
Tbl1001."AssociatedEmployeeID"=?))
And not as expected, and opposite as documented, only the matching rows are
returned - and the filter is applied on the remote server.
But wait! Now i will try to filter by a uniqueidentifer:
SELECT ActionItemID FROM ActionItems
WHERE AssociatedEmployeeID is not null
StmtText
-------
|--Filter(WHERE:([Jango].[CasinoHR].[dbo].[ActionItems1].[AssociatedEmployeeID]<>NULL))
|--Remote Query(SOURCE:(Jango), QUERY:(SELECT
Tbl1001."AssociatedEmployeeID" Col1005,Tbl1001."ActionItemID" Col1003 FROM
"CasinoHR"."dbo"."ActionItems1" Tbl1001))
And as expected and documented, all rows are returned, then a filter is
applied to get the one row.
But wait! Now i will try to filter by a uniqueidentifier:
SELECT ActionItemID FROM ActionItems
WHERE AssociatedActionItemID = 'C8A32A8F-2AF8-4B4A-9954-27274F4F6B01'
StmtText
-------
|--Remote Query(SOURCE:(Jango), QUERY:(SELECT Tbl1001."ActionItemID"
Col1004 FROM "CasinoHR"."dbo"."ActionItems1" Tbl1001 WHERE
Tbl1001."AssociatedActionItemID"=?))
And not as expected, and opposite as documented, only the matching rows are
returned - and the filter is applied on the remote server.
So what's up? Either SQL Server can pass a filter condition on a
uniqueidentifier field to the remote server, or it cannot. Which is it? The
documentation says it cannot. The documentation does not say that it cannot
except for sometimes - who's logic isn't apparent or logical.Oops, DPW should be DPV
Distributed Partitioned Views

Friday, March 23, 2012

FileTime

Is there a SQL function to get FileTime?
Filetime is a 64 bit number representing time(up to nano seconds) from
January 1, 1601 to what ever the time right now.
In C++/C# etc, you have functions to get his value or to convert file time
in system time. Ex;: Getfiletime()
FileTime 127512288251260000 is equivalent to '2005/01/26 16:00:25.126'
"Rick Sawtell" wrote:

> "uhway" <uhway@.discussions.microsoft.com> wrote in message
> news:B53A17CF-BFE1-4B37-8D0E-466859C445C8@.microsoft.com...
>
> What do you mean by filetime? Can you give an example of what the filetime
> data looks like?
>
> Rick Sawtell
> MCT, MCSD, MCDBA
>
>
You can use DATEDIFF(ms,startdate, GETDATE())
where ms stands for milliseconds, startdate is a your own starting date, and
getdate is the system function that returns the current date, up to
milliseconds.
Francesco Anti
"uhway" <uhway@.discussions.microsoft.com> wrote in message
news:E0DD2F8B-F244-435D-99A5-105D368AC8D6@.microsoft.com...[vbcol=seagreen]
> Is there a SQL function to get FileTime?
> Filetime is a 64 bit number representing time(up to nano seconds) from
> January 1, 1601 to what ever the time right now.
> In C++/C# etc, you have functions to get his value or to convert file time
> in system time. Ex;: Getfiletime()
> FileTime 127512288251260000 is equivalent to '2005/01/26 16:00:25.126'
> "Rick Sawtell" wrote:
filetime
>
|||One thing to remember is that since SQL Server DateTime has less reolution,
you can do a direct comparison.
"Francesco Anti" <fanti @. sicosbt.it> wrote in message
news:ed2YskSBFHA.608@.TK2MSFTNGP15.phx.gbl...
> You can use DATEDIFF(ms,startdate, GETDATE())
> where ms stands for milliseconds, startdate is a your own starting date,
and[vbcol=seagreen]
> getdate is the system function that returns the current date, up to
> milliseconds.
> Francesco Anti
> "uhway" <uhway@.discussions.microsoft.com> wrote in message
> news:E0DD2F8B-F244-435D-99A5-105D368AC8D6@.microsoft.com...
time
> filetime
>

FileTime

Is there a sql function for FileTime?
Filetime is a 64 bit number representing time(up to nano seconds) from
January 1, 1601 to what ever the time right now.
In C++/C# etc, you have functions to get his value or to convert file time
in system time. Ex;: Getfiletime()
FileTime 127512288251260000 is equivalent to '2005/01/26 16:00:25.126'
"Rick Sawtell" wrote:

> "uhway" <uhway@.discussions.microsoft.com> wrote in message
> news:B53A17CF-BFE1-4B37-8D0E-466859C445C8@.microsoft.com...
>
> What do you mean by filetime? Can you give an example of what the filetime
> data looks like?
>
> Rick Sawtell
> MCT, MCSD, MCDBA
>
>
No, not built-in; I guess the only way would be to create your own UDF.
Dejan Sarka, SQL Server MVP
Associate Mentor
www.SolidQualityLearning.com
"uhway" <uhway@.discussions.microsoft.com> wrote in message
news:755BB301-090D-4D92-94E1-30D91A112A10@.microsoft.com...[vbcol=seagreen]
> Is there a sql function for FileTime?
>
> Filetime is a 64 bit number representing time(up to nano seconds) from
> January 1, 1601 to what ever the time right now.
> In C++/C# etc, you have functions to get his value or to convert file time
> in system time. Ex;: Getfiletime()
> FileTime 127512288251260000 is equivalent to '2005/01/26 16:00:25.126'
> "Rick Sawtell" wrote:
filetime
>

FileTime

Is there a SQL function to get FileTime?
Filetime is a 64 bit number representing time(up to nano seconds) from
January 1, 1601 to what ever the time right now.
In C++/C# etc, you have functions to get his value or to convert file time
in system time. Ex;: Getfiletime()
FileTime 127512288251260000 is equivalent to '2005/01/26 16:00:25.126'
"Rick Sawtell" wrote:

> "uhway" <uhway@.discussions.microsoft.com> wrote in message
> news:B53A17CF-BFE1-4B37-8D0E-466859C445C8@.microsoft.com...
>
> What do you mean by filetime? Can you give an example of what the fileti
me
> data looks like?
>
> Rick Sawtell
> MCT, MCSD, MCDBA
>
>You can use DATEDIFF(ms,startdate, GETDATE())
where ms stands for milliseconds, startdate is a your own starting date, and
getdate is the system function that returns the current date, up to
milliseconds.
Francesco Anti
"uhway" <uhway@.discussions.microsoft.com> wrote in message
news:E0DD2F8B-F244-435D-99A5-105D368AC8D6@.microsoft.com...
> Is there a SQL function to get FileTime?
> Filetime is a 64 bit number representing time(up to nano seconds) from
> January 1, 1601 to what ever the time right now.
> In C++/C# etc, you have functions to get his value or to convert file time
> in system time. Ex;: Getfiletime()
> FileTime 127512288251260000 is equivalent to '2005/01/26 16:00:25.126'
> "Rick Sawtell" wrote:
>
filetime[vbcol=seagreen]
>|||One thing to remember is that since SQL Server DateTime has less reolution,
you can do a direct comparison.
"Francesco Anti" <fanti @. sicosbt.it> wrote in message
news:ed2YskSBFHA.608@.TK2MSFTNGP15.phx.gbl...
> You can use DATEDIFF(ms,startdate, GETDATE())
> where ms stands for milliseconds, startdate is a your own starting date,
and
> getdate is the system function that returns the current date, up to
> milliseconds.
> Francesco Anti
> "uhway" <uhway@.discussions.microsoft.com> wrote in message
> news:E0DD2F8B-F244-435D-99A5-105D368AC8D6@.microsoft.com...
time[vbcol=seagreen]
> filetime
>

FileTime

Is there a sql function for FileTime?
Filetime is a 64 bit number representing time(up to nano seconds) from
January 1, 1601 to what ever the time right now.
In C++/C# etc, you have functions to get his value or to convert file time
in system time. Ex;: Getfiletime()
FileTime 127512288251260000 is equivalent to '2005/01/26 16:00:25.126'
"Rick Sawtell" wrote:

> "uhway" <uhway@.discussions.microsoft.com> wrote in message
> news:B53A17CF-BFE1-4B37-8D0E-466859C445C8@.microsoft.com...
>
> What do you mean by filetime? Can you give an example of what the fileti
me
> data looks like?
>
> Rick Sawtell
> MCT, MCSD, MCDBA
>
>No, not built-in; I guess the only way would be to create your own UDF.
Dejan Sarka, SQL Server MVP
Associate Mentor
www.SolidQualityLearning.com
"uhway" <uhway@.discussions.microsoft.com> wrote in message
news:755BB301-090D-4D92-94E1-30D91A112A10@.microsoft.com...
> Is there a sql function for FileTime?
>
> Filetime is a 64 bit number representing time(up to nano seconds) from
> January 1, 1601 to what ever the time right now.
> In C++/C# etc, you have functions to get his value or to convert file time
> in system time. Ex;: Getfiletime()
> FileTime 127512288251260000 is equivalent to '2005/01/26 16:00:25.126'
> "Rick Sawtell" wrote:
>
filetime[vbcol=seagreen]
>sql

FileTime

Is there a sql function for FileTime?
Filetime is a 64 bit number representing time(up to nano seconds) from
January 1, 1601 to what ever the time right now.
In C++/C# etc, you have functions to get his value or to convert file time
in system time. Ex;: Getfiletime()
FileTime 127512288251260000 is equivalent to '2005/01/26 16:00:25.126'
"Rick Sawtell" wrote:
>
> "uhway" <uhway@.discussions.microsoft.com> wrote in message
> news:B53A17CF-BFE1-4B37-8D0E-466859C445C8@.microsoft.com...
> > How can I convert filetime to datetime in sql server inside a sored
> > procedure.
> >
> > Thanks
> > BVR
>
>
> What do you mean by filetime? Can you give an example of what the filetime
> data looks like?
>
>
> Rick Sawtell
> MCT, MCSD, MCDBA
>
>
>
>No, not built-in; I guess the only way would be to create your own UDF.
--
Dejan Sarka, SQL Server MVP
Associate Mentor
www.SolidQualityLearning.com
"uhway" <uhway@.discussions.microsoft.com> wrote in message
news:755BB301-090D-4D92-94E1-30D91A112A10@.microsoft.com...
> Is there a sql function for FileTime?
>
> Filetime is a 64 bit number representing time(up to nano seconds) from
> January 1, 1601 to what ever the time right now.
> In C++/C# etc, you have functions to get his value or to convert file time
> in system time. Ex;: Getfiletime()
> FileTime 127512288251260000 is equivalent to '2005/01/26 16:00:25.126'
> "Rick Sawtell" wrote:
> >
> > "uhway" <uhway@.discussions.microsoft.com> wrote in message
> > news:B53A17CF-BFE1-4B37-8D0E-466859C445C8@.microsoft.com...
> > > How can I convert filetime to datetime in sql server inside a sored
> > > procedure.
> > >
> > > Thanks
> > > BVR
> >
> >
> > What do you mean by filetime? Can you give an example of what the
filetime
> > data looks like?
> >
> >
> > Rick Sawtell
> > MCT, MCSD, MCDBA
> >
> >
> >
> >
>