Thursday, February 9, 2012

permissions for sql system views

for some bizzare reason db_datareader was not enough to retrieve info from the system views - but they didnt fail either - just didnt return info

when I added db_ddladmin the queries returned correctly

Wednesday, February 8, 2012

recursively run procedure through chain of ancestors

protected override void Foo()
{
    try
    {
    

    }
    finally
    {
        base.Foo();
    }
}

Wednesday, February 1, 2012

gettysburg

which owner owns which schema

SELECT
FROM
s.name,p.name sys.schemas s inner join sys.database_principals p on s.principal_id = USER_ID(p.name)

> any acts as > min

select *
from
(
select 'a' chr
union select 'b'
union select 'c'
union select 'd'
union select 'e'
) main

where main.chr > any
 (
 select 'a' chr
union select 'b'
union select 'c'
 )

> all acts as a max

select *
from
(
select 'a' chr
union select 'b'
union select 'c'
union select 'd'
union select 'e'
) main

where main.chr > all
 (
 select 'a' chr
union select 'b'
union select 'c'
 )

difference between <> any and not in


select *
from
(
select 'a' chr
union select 'b'
union select 'c'
union select 'd'
union select 'e'
) main

where main.chr not in ('a','b','c')

returns d,e

select *
from
(
select 'a' chr
union select 'b'
union select 'c'
union select 'd'
union select 'e'
) main

where main.chr <> any
 (
 select 'a' chr
union select 'b'
union select 'c'
 )
returns a,b,c,d,e and is nonsensical