November 8, 2018 at 8:38 am
Hi;
I am trying to get all objects created and or modified during last week, but instead the query returns very old data
select name, type,type_desc, create_date, modify_date
from sys.objects
where create_date between '2018-10-22'and '2018-11-02'
and type = 'U' or type = 'P' or type = 'fn';
type | type_desc | name | create_date | modify_date |
FN | SQL_SCALAR_FUNCTION | GetFondosPartidasDescripcioneswithAmount | 2/12/2014 | 6/27/2017 |
FN | SQL_SCALAR_FUNCTION | fnGetTypeFund | 11/1/2018 | 11/1/2018 |
FN | SQL_SCALAR_FUNCTION | CIntToChar | 11/1/2018 | 11/1/2018 |
FN | SQL_SCALAR_FUNCTION | CalculateCheckDigitUPC | 11/1/2018 | 11/1/2018 |
FN | SQL_SCALAR_FUNCTION | SetControlNumber | 11/2/2018 | 11/2/2018 |
FN | SQL_SCALAR_FUNCTION | funcAnioFiscal | 6/6/2012 | 6/6/2012 |
FN | SQL_SCALAR_FUNCTION | fn_diagramobjects | 11/5/2018 | 11/5/2018 |
FN | SQL_SCALAR_FUNCTION | fnCalcage | 11/6/2018 | 11/6/2018 |
FN | SQL_SCALAR_FUNCTION | fnCalcage2 | 11/7/2018 | 11/7/2018 |
FN | SQL_SCALAR_FUNCTION | GetUserEmails | 10/31/2014 | 10/31/2014 |
FN | SQL_SCALAR_FUNCTION | GetFondosPartidasDescripciones | 8/20/2013 | 8/22/2013 |
November 8, 2018 at 9:00 am
Orestes - Thursday, November 8, 2018 8:38 AMHi;I am trying to get all objects created and or modified during last week, but instead the query returns very old data
select name, type,type_desc, create_date, modify_date
from sys.objects
where create_date between '2018-10-22'and '2018-11-02'
and type = 'U' or type = 'P' or type = 'fn';
type type_desc name create_date modify_date FN SQL_SCALAR_FUNCTION GetFondosPartidasDescripcioneswithAmount 2/12/2014 6/27/2017 FN SQL_SCALAR_FUNCTION fnGetTypeFund 11/1/2018 11/1/2018 FN SQL_SCALAR_FUNCTION CIntToChar 11/1/2018 11/1/2018 FN SQL_SCALAR_FUNCTION CalculateCheckDigitUPC 11/1/2018 11/1/2018 FN SQL_SCALAR_FUNCTION SetControlNumber 11/2/2018 11/2/2018 FN SQL_SCALAR_FUNCTION funcAnioFiscal 6/6/2012 6/6/2012 FN SQL_SCALAR_FUNCTION fn_diagramobjects 11/5/2018 11/5/2018 FN SQL_SCALAR_FUNCTION fnCalcage 11/6/2018 11/6/2018 FN SQL_SCALAR_FUNCTION fnCalcage2 11/7/2018 11/7/2018 FN SQL_SCALAR_FUNCTION GetUserEmails 10/31/2014 10/31/2014 FN SQL_SCALAR_FUNCTION GetFondosPartidasDescripciones 8/20/2013 8/22/2013
Your problem is not knowing the precedence of AND and OR in your query. Try this:
select [name]
, [type]
, [type_desc]
, [create_date]
, [modify_date]
from [sys].[objects]
where [create_date]
between '2018-10-22' and '2018-11-02'
and ([type] = 'U'
or [type] = 'P'
or [type] = 'fn');
November 8, 2018 at 9:52 am
thank you.... you are complete right i do forgot that !!!!
November 8, 2018 at 10:17 am
Lynn Pettis - Thursday, November 8, 2018 9:00 AMOrestes - Thursday, November 8, 2018 8:38 AMHi;I am trying to get all objects created and or modified during last week, but instead the query returns very old data
select name, type,type_desc, create_date, modify_date
from sys.objects
where create_date between '2018-10-22'and '2018-11-02'
and type = 'U' or type = 'P' or type = 'fn';
type type_desc name create_date modify_date FN SQL_SCALAR_FUNCTION GetFondosPartidasDescripcioneswithAmount 2/12/2014 6/27/2017 FN SQL_SCALAR_FUNCTION fnGetTypeFund 11/1/2018 11/1/2018 FN SQL_SCALAR_FUNCTION CIntToChar 11/1/2018 11/1/2018 FN SQL_SCALAR_FUNCTION CalculateCheckDigitUPC 11/1/2018 11/1/2018 FN SQL_SCALAR_FUNCTION SetControlNumber 11/2/2018 11/2/2018 FN SQL_SCALAR_FUNCTION funcAnioFiscal 6/6/2012 6/6/2012 FN SQL_SCALAR_FUNCTION fn_diagramobjects 11/5/2018 11/5/2018 FN SQL_SCALAR_FUNCTION fnCalcage 11/6/2018 11/6/2018 FN SQL_SCALAR_FUNCTION fnCalcage2 11/7/2018 11/7/2018 FN SQL_SCALAR_FUNCTION GetUserEmails 10/31/2014 10/31/2014 FN SQL_SCALAR_FUNCTION GetFondosPartidasDescripciones 8/20/2013 8/22/2013 Your problem is not knowing the precedence of AND and OR in your query. Try this:
select [name]
, [type]
, [type_desc]
, [create_date]
, [modify_date]
from [sys].[objects]
where [create_date]
between '2018-10-22' and '2018-11-02'
and ([type] = 'U'
or [type] = 'P'
or [type] = 'fn');
Tank you, I totally forgot that !!!!
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply