Thursday, June 26, 2014

view all subscriptions in Reporting Services



SELECT
       c.Name
       ,c.Description
       ,C.Path
       ,sub.SubscriptionID -- ReportServer.dbo.AddEvent @EventType='TimedSubscription', @EventData=''
       ,sub.Description
       ,sub.LastStatus
       ,sub.LastRunTime
       ,sc.enddate
FROM dbo.Catalog AS c
   INNER JOIN dbo.ReportSchedule AS rs
       ON rs.ReportID =c.itemid
   INNER JOIN dbo.Schedule AS sc
       ON sc.ScheduleID= rs.ScheduleID
   INNER JOIN dbo.Subscriptions AS sub
       ON rs.SubscriptionID =sub.SubscriptionID

View Subscription

SELECT
c.Name AS ReportName
, c.Type
, c.Description AS ReportDescription
, u.UserName AS ReportCreatedBy
, s.Description AS SubscriptionDescription
, s.DeliveryExtension AS SubscriptionDelivery
, su.UserName AS SubscriptionOwner
, s.LastStatus
, s.LastRunTime
, s.Parameters
,sch.StartDate AS ScheduleStarted
,sch.LastRunTime AS LastSubRun
, sch.NextRunTime
, d.Name AS DataSource
, c.Path
FROM
Catalog c
LEFT OUTER JOIN  Subscriptions s ON c.ItemID = s.Report_OID
INNER JOIN  DataSource d ON c.ItemID = d.ItemID
LEFT OUTER JOIN  Users u ON u.UserID = c.CreatedByID
LEFT OUTER JOIN ReportSchedule rs ON c.ItemID = rs.ReportID
LEFT OUTER JOIN  Schedule sch ON rs.ScheduleID = sch.ScheduleID
LEFT OUTER JOIN Users su on s.ownerID = su.UserID
WHERE
c.Type = 2
and s.SubscriptionID is not null
ORDER BY c.Name

Friday, May 9, 2014

currency Conversion Languge settings for symbols in SSAS



Language ([Destination Currency].[Currency].&[2])=1027;  --- EUR
Language ([Destination Currency].[Currency].&[3])=1046;  --- Brazilian Real
Language ([Destination Currency].[Currency].&[4])=2057;   --- GBP
Language ([Destination Currency].[Currency].&[5])=3076;   ---HKD
Language ([Destination Currency].[Currency].&[6])=2052;  ---Chinese Yuan CNY
Language ([Destination Currency].[Currency].&[1])=1033;  --- USD

Friday, May 2, 2014

T-sql Query to update all NULL values with Empty String in all columns of a table

select 'update ' + table_name + ' set [' + column_name + '] = '  +
 CASE
    WHEN DATA_TYPE = 'bit' THEN '0'
    WHEN DATA_TYPE = 'int' THEN '0'
    WHEN DATA_TYPE = 'decimal' THEN '0'
    WHEN DATA_TYPE = 'date' THEN '''1/1/1900'''
    WHEN DATA_TYPE = 'datetime' THEN '''1/1/1900'''
    WHEN DATA_TYPE = 'uniqueidentifier' THEN '00000000-0000-0000-0000-000000000000'
    ELSE '''''' -- everything else get's an empty string
  END
+

' where [' + column_name + '] is null'
from information_schema.columns
where table_name = 'YourTable'
select 'update ' + table_name + ' set [' + column_name + '] = '''' where [' + column_name + '] is null'
from information_schema.columns
where table_name = 'yourtable'
SELECT 'ISNULL(' + COLUMN_NAME + ',' + 
  CASE 
    WHEN DATA_TYPE = 'bit' THEN '0'
    WHEN DATA_TYPE = 'int' THEN '0'
    WHEN DATA_TYPE = 'decimal' THEN '0'
    WHEN DATA_TYPE = 'date' THEN '''1/1/1900'''
    WHEN DATA_TYPE = 'datetime' THEN '''1/1/1900'''
    WHEN DATA_TYPE = 'uniqueidentifier' THEN '00000000-0000-0000-0000-000000000000'
    ELSE '''''' -- everything else get's an empty string
  END + ') AS ' + COLUMN_NAME + ','
FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'TableName'

Monday, January 13, 2014

Find Parents


;with cte as
(
      select employeeid, supervisorid, cast(employeeid as varchar(max)) as [list], 0 [level]
      from employee
      where employeeid = 'xxxx'
     
      union all
     
      select e.employeeid, e.supervisorid, cast(cte.list + ',' + e.employeeid as varchar(max)) as [list], level + 1
      from employee e
            inner join cte on cte.supervisorid = e.employeeid
      where cte.list not like '%' + e.employeeid + '%'
)

select * from cte order by level