Friday, March 30, 2012
Is user allowed?
hoping someone has a shortcut.
How can you figure out if a User_Name is allowed in a specific role? Ok,
sounds easy at first, but what roles that that role is a sub-role of?
That's where it's gotten more complex than I thought --
So, pretend that we've got MasterRole of which BabyRole is a member. MyUser
is a member of BabyRole. And since BabyRole is a member of MasterRole,
MyUser is allowed to do all the things that MasterRoll can do. However if I
run sp_helplogins on MyUser, it will list BabyRole but not MasterRole. Is
there any sp or easy code that can enumerate all those roles (or even
better, is there any sp that I can call with a role name and a user and it
returns if the user is allowed in that role?)
TIA!Duhhh.. Ok, I found the command IS_MEMBER... I feel dummmbbb... Sorry to
waste the bandwidth :)
"Brett Wickard" <brettwickard@.nospam.nospam> wrote in message
news:OX7xqibfGHA.4828@.TK2MSFTNGP05.phx.gbl...
>I thought this would be easy, but it's now seeming way more complex - so
>I'm hoping someone has a shortcut.
> How can you figure out if a User_Name is allowed in a specific role? Ok,
> sounds easy at first, but what roles that that role is a sub-role of?
> That's where it's gotten more complex than I thought --
> So, pretend that we've got MasterRole of which BabyRole is a member.
> MyUser is a member of BabyRole. And since BabyRole is a member of
> MasterRole, MyUser is allowed to do all the things that MasterRoll can do.
> However if I run sp_helplogins on MyUser, it will list BabyRole but not
> MasterRole. Is there any sp or easy code that can enumerate all those
> roles (or even better, is there any sp that I can call with a role name
> and a user and it returns if the user is allowed in that role?)
> TIA!
>
>sql
Monday, February 20, 2012
Is there any easy way to evaluate complex date logic in expressions?
Hello all,
I am new to SSIS, so I am hoping there is an easier way to do this...
I need to evaluate a date in a field and determine if it is between the beginning and end of whatever the current month is... In Access, this was written as something like:
IIF(datevalue >= CDate(Format(Now(),"mm/01/yy")) AND datevalue < CDate(Format(DateAdd("m",1,Now()), "mm/01/yy)), value1, value2)
Trying to recreate this in SSIS using expressions during a derived transformation has been extremely difficult. Here is what I came up with:
(DUE_DATE >= (DT_DATE)( (DT_WSTR,2)MONTH(GETDATE())+"/01/"+ (DT_WSTR,2)YEAR(GETDATE()))) && (DUE_DATE<(DT_DATE)( (DT_WSTR,2)MONTH( DATEADD("m",1,GETDATE()) )+"/01/"+(DT_WSTR,2)YEAR( DATEADD("m",1,GETDATE() )))) ? value1 : value2
Any help you all could give would be appreciated.
Thanks!
Josh
I've just given this a go with a column called [OrderDate] (which comes from a SalesOrderHeader in AdventureWorks). The following works fine for me:
OrderDate < GETDATE() ? "Y" : "N"
Can you not do that? Why are you trying to parse out the different parts of GETDATE()?
-Jamie
|||This expression will determine if the DUE_DATE is in the current month, as defined by GETDATE().
YEAR(GETDATE()) + MONTH(GETDATE()) == YEAR(DUE_DATE) + MONTH(DUE_DATE) ? "value1" : "value2"
|||
jaegd wrote:
This expression will determine if the DUE_DATE is in the current month, as defined by GETDATE().
YEAR(GETDATE()) + MONTH(GETDATE()) == YEAR(DUE_DATE) + MONTH(DUE_DATE) ? "value1" : "value2"
I would suggest using :
(YEAR(GETDATE())*100) + MONTH(GETDATE()) == (YEAR(DUE_DATE)*100) + MONTH(DUE_DATE) ? "value1" : "value2"
That will result in 200612 for Dec 2006.
|||
Hi Jaimie,
Thanks for the advice. However, I need to be able to tell if the due_date is between the 1st and last day of the currernt (or any given) month. I think your suggestion would return true for all orders with a due_date less than today... which would exclude orders due in the remainder of the month and would include orders due prior to the beginning of the month.
Best regards,
Joshua
|||
Hi Tom,
Thanks for the help! I think that will do what I'm looking for and will be a lot easier...
Best regards,
Joshua
|||jrbarker33 wrote:
Hi Jaimie,
Thanks for the advice. However, I need to be able to tell if the due_date is between the 1st and last day of the currernt (or any given) month. I think your suggestion would return true for all orders with a due_date less than today... which would exclude orders due in the remainder of the month and would include orders due prior to the beginning of the month.
Best regards,
Joshua
Whoops. Sorry. I need to read things more accurately!
Tom's code is definately the way to go then.
-Jamie