European Windows 2012 Hosting BLOG

BLOG about Windows 2012 Hosting and SQL 2012 Hosting - Dedicated to European Windows Hosting Customer

SQL Server 2014 Hosting - HostForLIFE.eu :: How To Check Available Column in A Table

clock January 5, 2016 21:50 by author Rebecca

In this tutorial, we will share to you how to check available colum in a table. If you want to check if the column is already available in the table, you can use system views like sys.columns or INFORMATION_SCHEMA.COLUMNS.

Step 1

First, let us create the dataset:

USE TEMPDB;
CREATE TABLE TESTING(ID INT, NAME VARCHAR(100))

Step 2

Suppose you want to find out the existence of the column named NAME and print a message. You can do it by using any of the following methods:

IF EXISTS
(
SELECT * FROM SYS.COLUMNS
WHERE NAME='NAME' AND OBJECT_ID=OBJECT_ID('TESTING')
)
PRINT 'COLUMN EXISTS'
--
IF EXISTS
(
SELECT TABLE_NAME,COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME='NAME' AND TABLE_NAME='TESTING'
)
PRINT 'COLUMN EXISTS'

There is also a shorter way to do this. You can use COL_LENGTH system function:

IF (SELECT COL_LENGTH('TESTING','NAME')) IS NOT NULL
PRINT 'COLUMN EXISTS'

What it does is that it finds the length of the column. If it is null, the column does not exist in the table otherwise it exists.

Simple and fast, right?

HostForLIFE.eu SQL Server 2014 Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.



SQL Server 2012 Hosting - HostForLIFE.eu :: Managing Number of SQL Server ErrorLog

clock January 5, 2016 21:36 by author Peter

Microsoft SQL Server saves 7 errorlog files by default. When new errorlog is made, the recent one will be deleted at identical time. If you wish to keep a lot of errorlog, you'll follow 2 ways below to manage number of SQL Server ErrorLog, including both increasing and decreasing ErrorLog number.
Method 1: configure SQL Server ErrorLog number in SSMS
Step 1: Open SQL Server Management Studio. connect with SQL Server with SQL Server Authentication.

Tips: If user account password forgot, you'll only reset user password or change user forgotten password. So login to SQL Server with SQL Server Authentication and new user password. Otherwise, even though you'll successfully connect with SQL Server with Windows Authentication, the following error still occurs as soon as you want to configure SQL Server logs.

Step 2: Navigate to Management > SQL Server Logs. Right-click on SQL Server Logs and choose Configure.

Step 3: In pop-up window Configure SQL Server Error Logs, tick the box "Limit the number of error log files before they are recycling". And set "Maximum number of error log" with willing number. Save changes at last before you close this window.

Method 2: Change Number of SQL Server ErrorLog in Registry Editor

Step 1: First, type regedit in Start box, and press Enter to run Registry Editor.

Step 2: Now, Locate to the following path(1 or 2) and create a new entry in registry editor.
1. Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\SQLEXPRESS\MSSQLServer
2. Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ MSSQLServer\MSSQLServer

Right-click in the right blank pane of registry editor, and tap New > QWORD (64-bit) Value button in pop-up options.


Step 3: Rename the entry as NumErrorLogs and double-click it to edit its value. Type a number that you want to save SQL Server ErrorLog file. Tick Decimal under Base and click OK.

Close Registry Editor and finish setting on increasing or decreasing number of SQL Server Errorog file.

HostForLIFE.eu SQL Server 2012 Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.



SQL Server 2014 Hosting - HostForLIFE.eu :: How to Add Primary Key to Existing Table

clock December 8, 2015 23:28 by author Peter

I have an existing table referred to as Persion. in this table I actually have five columns:
persionId
Pname
PMid
Pdescription
Pamt

When I created this table, I set PersionId and Pname because the primary key. I now wish to include an extra column within the primary key - PMID. however can i write an ALTER statement to try and do this? (I already have 1000 records in the table). First, you can drop constraint and recreate it with the following code:
alter table Persion drop CONSTRAINT <constraint_name>
alter table Persion add primary key (persionId,Pname,PMID)


You can find the constraint name by using the code below:
select OBJECT_NAME(OBJECT_ID) AS NameofConstraint
FROM sys.objects
where OBJECT_NAME(parent_object_id)='Persion'
and type_desc LIKE '%CONSTRAINT'


I think something like this should work
-- drop current primary key constraint
ALTER TABLE dbo.persion
DROP CONSTRAINT PK_persionId;
GO

-- add new auto incremented field
ALTER TABLE dbo.persion
ADD pmid BIGINT IDENTITY;
GO

-- create new primary key constraint
ALTER TABLE dbo.persion
ADD CONSTRAINT PK_persionId PRIMARY KEY NONCLUSTERED (pmid, persionId);
GO

HostForLIFE.eu SQL Server 2014 Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.



SQL Server 2012 Hosting - HostForLIFE.eu:: How to Configuring a Server Side Trace in SQL Server 2012?

clock November 24, 2015 19:37 by author Peter

When I’m after SQL Server performance problems, SQL Server Profiler is still my beloved tool. Allthough i do know that extended events offer a mor light-weight answer, those are still a bit cumbersome to use (but I’ve seen that we are able to expect some enhancements with SQL Server 2012).

When I’m using profiler to isolate performance problems, I attempt to tack server side traces, whenever doable. luckily, SQL Server Profiler can assist you making a script for a server side trace (File/Export/Script Trace Definition), so you don’t have to figure out all the event- and column-codes. As i used to be doing a similar configuration again and again, i made a decision to separate the TSQL code for the configuration within a stored procedure.

And here comes dbo.configureServerSideTrace:
if object_id('dbo.configureServerSideTrace', 'P') is not null
drop procedure dbo.configureServerSideTrace
go

-- Example for:
-- Start Trace
--   declare @traceID int
--   exec dbo.configureServerSideTrace @traceStatus = 1
--                                    ,@traceID = @traceID output
--                                    ,@maxFileSize = 10000
--                                    ,@traceFileName = N'e:\VMITrace\Undo'
--                                    ,@spId = @@spid
--
-- End Trace
--   exec dbo.configureServerSideTrace @traceStatus = 0, @traceID = @traceID

create procedure dbo.configureServerSideTrace
             (@traceStatus   bit                  -- 1 => Start Trace
                                                  -- 0 => Stop Trace
             ,@traceID       int output           -- If the Trace is started, this param will return the TraceID
                                                  -- For stopping the trace, the param has to be provided
             ,@spId          int           = null -- provide the @@spid, if you want to filter only events for this conection
                                                  -- Optional. If not provided => no filter. Not needed for stopping the trace
             ,@maxFileSize   bigint        = 5000 -- Maximum Trace File Size in Megabyte. Trace will be stopped, if the filesize is reached.
             ,@traceFileName nvarchar(200) = null -- Name of the trace file (server side!)
                                                  -- Optional. Not neded for stoping the trace
                                                  -- Attention! If the file already exists, the SP will yield an error
                                                  -- and no trace is started.
             ) as
begin

if (@traceStatus = 0)
begin
exec sp_trace_setstatus @TraceID, 0
exec sp_trace_setstatus @TraceID, 2
return;
end

-- Create a Queue
declare @rc int

exec @rc = sp_trace_create @TraceID output, 0, @traceFileName, @maxfilesize, NULL
if (@rc != 0) goto error

-- Set the events
declare @on bit
set @on = 1
exec sp_trace_setevent @TraceID, 43, 15, @on
exec sp_trace_setevent @TraceID, 43, 48, @on
exec sp_trace_setevent @TraceID, 43, 1, @on
exec sp_trace_setevent @TraceID, 43, 34, @on
exec sp_trace_setevent @TraceID, 43, 35, @on
exec sp_trace_setevent @TraceID, 43, 51, @on
exec sp_trace_setevent @TraceID, 43, 4, @on
exec sp_trace_setevent @TraceID, 43, 12, @on
exec sp_trace_setevent @TraceID, 43, 13, @on
exec sp_trace_setevent @TraceID, 43, 14, @on
exec sp_trace_setevent @TraceID, 43, 22, @on
exec sp_trace_setevent @TraceID, 42, 1, @on
exec sp_trace_setevent @TraceID, 42, 14, @on
exec sp_trace_setevent @TraceID, 42, 22, @on
exec sp_trace_setevent @TraceID, 42, 34, @on
exec sp_trace_setevent @TraceID, 42, 35, @on
exec sp_trace_setevent @TraceID, 42, 51, @on
exec sp_trace_setevent @TraceID, 42, 4, @on
exec sp_trace_setevent @TraceID, 42, 12, @on
exec sp_trace_setevent @TraceID, 45, 16, @on
exec sp_trace_setevent @TraceID, 45, 48, @on
exec sp_trace_setevent @TraceID, 45, 1, @on
exec sp_trace_setevent @TraceID, 45, 17, @on
exec sp_trace_setevent @TraceID, 45, 18, @on
exec sp_trace_setevent @TraceID, 45, 34, @on
exec sp_trace_setevent @TraceID, 45, 35, @on
exec sp_trace_setevent @TraceID, 45, 51, @on
exec sp_trace_setevent @TraceID, 45, 4, @on
exec sp_trace_setevent @TraceID, 45, 12, @on
exec sp_trace_setevent @TraceID, 45, 13, @on
exec sp_trace_setevent @TraceID, 45, 14, @on
exec sp_trace_setevent @TraceID, 45, 22, @on
exec sp_trace_setevent @TraceID, 45, 15, @on
-- XML Statistics Profile
exec sp_trace_setevent @TraceID, 146, 1, @on
exec sp_trace_setevent @TraceID, 146, 51, @on
exec sp_trace_setevent @TraceID, 146, 4, @on
exec sp_trace_setevent @TraceID, 146, 12, @on

-- Filter: Log only events for the provided @@spid
if @spId is not null
exec sp_trace_setfilter @TraceID, 12, 0, 0, @spID

-- Set the trace status to start
exec sp_trace_setstatus @TraceID, 1

goto finish

error:
select ErrorCode=@rc

finish:
end
go


Some annotations:

  • For the parameters, see the comments.
  • Don’t specify a string for the trace file. .TRC will be added automatically.
  • ensure that the output file doesn't already exist. Otherwise you’ll get an error.
  • very often I replace the code for beginning and stopping the trace inside “interesting code” inside a stored procedure. That is, I’m wrapping some more or less awkward code by starting and stopping a trace like this:

declare @traceID int
exec dbo.configureServerSideTrace @traceStatus = 1
                                 ,@traceID = @traceID output
                                 ,@maxFileSize = 10000
                                 ,@traceFileName = N'e:\MyTrace\Test'
                                 ,@spId = @@spid

--
-- Code of interest
--

exec dbo.configureServerSideTrace @traceStatus = 0, @traceID = @traceID

HostForLIFE.eu SQL Server 2014 Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.



European DotNetNuke 7 Hosting - UK :: What You Must DO and DON'T for Your DotNetNuke SEO

clock November 12, 2015 19:47 by author Scott

DotNetNuke is easily one of the most popular ASP .Net content management (CMS) systems out there. In this post I am going to cover some of the simplest, fastest things you can do to your DotNetNuke site in order to improve SEO. If your first question was “What is SEO?” then this post is for you. If you are familiar with SEO and want a quick refresher that pertains specifically to DotNetNuke then this post is for you. If you have already carefully tuned your site and are looking for advanced optimization techniques, go hire a marketing professional with a proven track record of SEO success.

So, what is SEO? The term SEO stands for Search Engine Optimization and it essentially means tweaking your site to make it more search-friendly. A search-friendly site makes it much easier for your current and potential customers to locate your site and to find what they need on your site. The end-goal of SEO is often more specifically about getting into one of the coveted top spots in Google’s search results for a particular term or phrase. While achieving that goal usually takes a lot more than the simple tips presented in this post (for example, Google’s ranking depends a lot on the number and types of other sites that link to you), these tips will get you started on the right path and will make your site more useful and usable in the process.

DO use a DotNetNuke (DNN) skin that is web standards-based and follows current recommended practices for accessible content. A good skin will probably note that it is XHTML or HTML5 compliant and may display a small W3C icon indicating that its code validates properly. The W3C is the internationally-recognized body responsible for setting standards that govern key web technologies. A good skin will not use tables for layout. You may also see references to Section 508, which refers to standards set forth in US law for make a site accessible to all users including those using screen readers and other assistive technology. Section 508-compliant sites tend to also be extremely search-friendly as they will include additional text and meta-data to serve assistive technology that is also useful to the robots used by Google, Bing, Yahoo and others.


DON’T make any key text into an image. In fact, avoid making any text into an image at all. Search engines cannot read any text from an image, and neither can screen readers for visually-impaired users. Web font services such as TypekitWebtype and Google Web Fonts make it easier than ever to replace images with plain text and maintain custom styling. If you must use an image for text, make sure that you properly define the alt tag of the image. This is something that is absolutely essential to do for all images on your site, not just those that contain text. In DotNetNuke you typically set up this text in the properties area when inserting an image. You can also configure an additional long description through this dialog where appropriate.


DO take advantage of the site-wide and page-level descriptions and keywords available in DNN. Most themes will use these elements in the header meta-tags of your site. While search engines never rely on keyword tags alone for indexing, these keywords can be useful for pointing out to the search engine which words on the page are particularly important. On the other hand, the description is typically used by search engines as the snippet that will be displayed in their search results. For this reason you should keep it short, to-the-point and self-explanatory. This is your chance to grab the attention of someone who is quickly scanning a search results page for relevant links. The site-wide description will often be used when no page-level description is present but you should always override it with a more specific description per page when possible to prevent the appearance of duplicate content and to give a better idea of what is actually on each page. You can set the description and keywords for the entire site in Site Settings and for an individual page while editing that page.


DON’T post misleading content, duplicate content on multiple pages or rip content from other sites on the web. Google in particular is known to penalize this type of behavior. This should be an obvious one as it is also clearly an ethical issue. The best way to attract the customers that are right for you is to post authentic, original content that benefits them in some way. If you find an article elsewhere that you think may be beneficial to your customers the best thing to do is to write your own post adding value to the discussion, including one or two short, properly-attributed quotes and linking to the full text on the original site. Who knows, this neighborly behavior could even lead to a productive relationship with the author of the content and perhaps a link back to your site from theirs at some future date.


DO update frequently, write plenty of informative text and try to include the words and phrases that you think customers will use when trying to search for the content you have written. Pay attention to the types of questions your customers are asking and how they are asking them. Try to think like a customer when writing and use the same terms that they would be likely to use when searching. Mention those things which are most distinguishing about you and that you want others to find out about you. By doing this not only will you make your content rank higher in search results but you will also make it far more relevant to your customers themselves. It is also a very good idea to include the keywords you identify in the titles of your pages or posts whenever it makes sense to do so – search engines tend to place special emphasis on URLs and titles.


DON’T rename or move pages unless absolutely necessary (and even then seriously consider creating a redirect from the old location to the new one). I should really say don’t rename or move pages ever. Changing the structure of your site can cause dead links both internally and externally. If someone has bookmarked a particular location or linked to it from a blog, web site or tweet and you move or rename that page the link will stop working and you will end up with missed opportunities and frustrated and alienated customers. Restructuring your site can also lead to a (usually temporary) search ranking penalty until your site is re-indexed by every major search provider. If you must move a page you can create a placeholder at the old location and use the DNN link/redirect options to make sure that people with only the old URL will still end up in the right place.


DO update frequently, write plenty of informative text and try to include the words and phrases that you think customers will use when trying to search for the content you have written. Pay attention to the types of questions your customers are asking and how they are asking them. Try to think like a customer when writing and use the same terms that they would be likely to use when searching. Mention those things which are most distinguishing about you and that you want others to find out about you. By doing this not only will you make your content rank higher in search results but you will also make it far more relevant to your customers themselves. It is also a very good idea to include the keywords you identify in the titles of your pages or posts whenever it makes sense to do so – search engines tend to place special emphasis on URLs and titles.


DON’T rename or move pages unless absolutely necessary (and even then seriously consider creating a redirect from the old location to the new one). I should really say don’t rename or move pages ever. Changing the structure of your site can cause dead links both internally and externally. If someone has bookmarked a particular location or linked to it from a blog, web site or tweet and you move or rename that page the link will stop working and you will end up with missed opportunities and frustrated and alienated customers. Restructuring your site can also lead to a (usually temporary) search ranking penalty until your site is re-indexed by every major search provider. If you must move a page you can create a placeholder at the old location and use the DNN link/redirect options to make sure that people with only the old URL will still end up in the right place.


DO use the semantic nature of HTML to add value to your content. An &lt;h1&gt; (Heading 1) tag should be the most important heading on your page. &lt;h2&gt; should be next and so forth, like an outline. The &lt;p&gt; should separate paragraphs. Addresses should be indicated with &lt;address&gt; and lists with &lt;ul&gt; (unordered) or &lt;ol&gt; (ordered). Links created with the &lt;a&gt; tag should include title attributes. Like many of the previous tips, producing well structured content helps both search engines and assistive devices parse your site with greater success. It also starts you down the path towards microformats and some of the advanced and exciting things being done with them. DNN makes at least the basics of this relatively easy without editing the actual code. You can simply choose the tag that will be used from the built in editor. When you do this, just remember that you are describing the text as well as styling it.

That’s it for today! I hope that these tips help you make your site more search- and user-friendly! 



SQL Reporting Service (SSRS) 2012 Hosting - HostForLIFE.eu :: How to Display SSRS Reports in Chrome, Firefox and Safari?

clock November 3, 2015 23:21 by author Peter

By default SSRS Reports do not render in Chrome, Firefox and Safari.  However, there's a hack that may be enforced to get this working. To fix the matter, we'd like to create a custom stylesheet for SSRS.  The new style sheet will use media queries to focus on the non-IE browsers.  So, In theory, i.e. won't be impacted using this solution.  This by no means that an ideal solution, and that i haven't had time to check it in every possible situation.  However, it's worked for me once I understand a user has to view a report in a non-IE browser.  It works best if you're hyper linking to a report from another location.

 

In SQL Server 2012,  you’ll find the SSRS css files located in 

C:\Program Files\Microsoft SQL Server\MSRS11.[Instance Name]\Reporting Services\ReportServer\Styles.

Create a new css file.  In the file paste the following styles:

@media screen and (-webkit-min-device-pixel-ratio:0)

{    div[style] {        overflow:visible !important;    }}@-moz-document url-prefix() {    div[style] {         overflow:visible !important;    }}

Then you will want to take the contents of the HtmlViewer.css file and paste it before the styles above.  From what I can tell, this will tell SSRS to override the entire default css file with the new css file.

In order to call the report with the new css file you will need to use the following url format:

http://[your server dns name]/[Your SSRS Instance Webservice Path]?[Report Path]&rc.StyleSheet=[the new css file name]

For the example

http://www.yourdomain.com/ReportServer?/MyReports/Reports/TestReport&rc:Stylesheet=NonIEStylesheet

where NonIEStylesheet is the name of the css file we placed into

C:\Program Files\Microsoft SQL Server\MSRS11.[Instance Name]\Reporting Services\ReportServer\Styles.  

Also notice we didn't use the /Reports/ endpoint for SSRS.  We have to use the /ReportServer/ endpoint.

HostForLIFE.eu SQL Reporting Service (SSRS) 2012 Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.

 



SQL Server 2014 Hosting - HostForLIFE.eu :: How to Check Last Accessed And Modified Table Data in SQL Server?

clock October 29, 2015 23:38 by author Peter

Now, I will guide you how to check last accessed and modified table data in SQL Data. And here is the script that I use:

/*************************************************/
SELECT OBJECT_NAME(OBJECT_ID) AS [Object_Name], last_user_update,last_user_scan  ,*
FROM sys.dm_db_index_usage_stats
WHERE database_id = DB_ID( 'Access') AND OBJECT_ID=OBJECT_ID('test')
/*************************************************/

--Note: This will return null if sql server restarted and after that data is not accessed

         Demo:
/**** Create New Database ****/
Create Database Access
GO
use Access
GO
/**** Create Table ****/
Create Table test (id int , name varchar (100))
GO
/**** Insert New Record ****/
Insert into test values (1,'saurabh')
Insert into test values (2,'Sumit')
GO
/**** After insertion Check Stats ****/
SELECT OBJECT_NAME(OBJECT_ID) AS [Object_Name], last_user_update,last_user_scan  ,*
FROM sys.dm_db_index_usage_stats WHERE database_id = DB_ID( 'Access') AND OBJECT_ID=OBJECT_ID('test')

Object_Name   last_user_update                  last_user_scan
test               2015-10-29 08:39:54.100           NULL

Here last user scan is null because we are just inserted data, If we read data then we'll get read time also
So now we are going to read data and see if we get last user scan. Now, write the following code:

Select * from access.dbo.test
GO
/**** Checking Stats ****/
SELECT OBJECT_NAME(OBJECT_ID) AS [Object_Name], last_user_update,last_user_scan  ,*
FROM sys.dm_db_index_usage_stats WHERE database_id = DB_ID( 'Access') AND OBJECT_ID=OBJECT_ID('test')


So here we just updated table , didnt read. You can see the result on the following picture:

Similarly if we want to see how current indexes are performing on table we can see user scan , user seek or look ups.

HostForLIFE.eu SQL Server 2014 Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.



SQL Server 2014 Hosting Tutorial - HostForLIFE.eu :: How to Detect Empty Row in A Table

clock October 28, 2015 03:14 by author Rebecca

Maybe you were recently doing a clean up of your website database, then you create some tables on your database but never adding any new rows to it. In this tutorial, I will tell you how to detect empty row in a table on SQL Server database.

Here's a simple query to list all empty rows in tables in your SQL Server database using a Dynamic Management View called dm_db_partition_stats. This will return page and row-count information for every partition in the current database:

;WITH EmptyRows AS
(
   SELECT SUM(row_count) AS [TotalRows],
          OBJECT_NAME(OBJECT_ID) AS TableName
   FROM sys.dm_db_partition_stats
   WHERE index_id = 0 OR index_id = 1
   GROUP BY OBJECT_ID
)
SELECT * FROM EmptyRows
WHERE [TotalRows] = 0

And here's the output:

Easy right?

HostForLIFE.eu SQL Server 2014 Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.



SQL Reporting Service (SSRS) 2012 Hosting - HostForLIFE.eu :: How to Fix Subscription Inventory, Failed Subscriptions in SSRS Utility Reports?

clock October 27, 2015 23:05 by author Peter

Today, let me show you How to Fix Subscription Inventory, Failed Subscriptions in SSRS Utility Reports. When delivering a SQL Server reporting Services (SSRS) solution with countless subscriptions, it's useful to conjointly include some utility reports regarding those subscriptions.

Here are a combine of queries you'll use against the ReportServer database (in this case, SQL Server 2014) to come up with some quick internal reports for an inventory of report subscriptions (who is receiving what, when, in what format, together with parameters?) and failed report subscriptions (what subscriptions have failed and why?), each with helpful info, timestamps and URL's.

Don't forget to alter the URL path's servername for these reports to reflect your own setup, keeping in mind that if you are using a named instance, the yourservername/Reports/ could look more like yourservername/Reports_instancename/.

 

Report Subscription Inventory:
This is an easy way to provide business users with an accurate and easy list of "who's getting what" that is pulled directly from the ReportServer metadata - it'll never be out of date and it's live.
SELECT Catalog.Name AS ReportName
,'http://yourservername/Reports/Pages/Report.aspx?ItemPath=' + Catalog.Path + '&SelectedTabId=PropertiesTab&SelectedSubTabId=SubscriptionsTab' AS ReportSubscriptionMgrUrl
,Subscriptions.Description AS SubscriptionDescription
,Subscriptions.LastStatus
,Subscriptions.LastRunTime
,'Next Run Date' = CASE next_run_date
WHEN 0 THEN null
ELSE
substring(convert(varchar(15),next_run_date),1,4) + '/' +
substring(convert(varchar(15),next_run_date),5,2) + '/' +
substring(convert(varchar(15),next_run_date),7,2)
END
, 'Next Run Time' = isnull(CASE len(next_run_time)
WHEN 3 THEN cast('00:0'
+ Left(right(next_run_time,3),1)
+':' + right(next_run_time,2) as char (8))
WHEN 4 THEN cast('00:'
+ Left(right(next_run_time,4),2)
+':' + right(next_run_time,2) as char (8))
WHEN 5 THEN cast('0' + Left(right(next_run_time,5),1)
+':' + Left(right(next_run_time,4),2)
+':' + right(next_run_time,2) as char (8))
WHEN 6 THEN cast(Left(right(next_run_time,6),2)
+':' + Left(right(next_run_time,4),2)
+':' + right(next_run_time,2) as char (8))
END,'NA')
 
,Subscriptions.Parameters
,ISNULL(
Convert(XML,[ExtensionSettings]).value('(//ParameterValue/Value[../Name="TO"])[1]','nvarchar(50)')
,Convert(XML,[ExtensionSettings]).value('(//ParameterValue/Value[../Name="PATH"])[1]','nvarchar(150)')
) as [To]
,
ISNULL(
 Convert(XML,[ExtensionSettings]).value('(//ParameterValue/Value[../Name="RenderFormat"])[1]','nvarchar(150)')
, Convert(XML,[ExtensionSettings]).value('(//ParameterValue/Value[../Name="RENDER_FORMAT"])[1]','nvarchar(150)')
) as [Render Format]
,Convert(XML,[ExtensionSettings]).value('(//ParameterValue/Value[../Name="Subject"])[1]','nvarchar(150)') as [Subject]
FROM [dbo].[ReportSchedule]
INNER JOIN [dbo].[Schedule]
ON ReportSchedule.ScheduleID = Schedule.ScheduleID
INNER JOIN [dbo].[Catalog]
ON ReportSchedule.ReportID = Catalog.ItemID
INNER JOIN [dbo].[Subscriptions]
ON ReportSchedule.SubscriptionID = Subscriptions.SubscriptionID
INNER JOIN [dbo].[Users]
ON Subscriptions.OwnerID = Users.UserID
INNER JOIN msdb.dbo.sysjobs J ON Convert(nvarchar(128),[ReportSchedule].ScheduleID) = J.name
INNER JOIN msdb.dbo.sysjobschedules JS ON J.job_id = JS.job_id

Report Subscription Failures:
Now, we allows the user to see if any subscriptions have failed most recently, for handling typical email or permissions errors, in the past 30 days. Because it uses the subscription's [laststatus] field (the same one you'll see in Report Manager), failures will drop off this report if they succeed again.
SELECT Catalog.Name AS ReportName
,'http://yourservername/Reports/Pages/Report.aspx?ItemPath=' + Catalog.Path + '&SelectedTabId=PropertiesTab&SelectedSubTabId=SubscriptionsTab' AS ReportSubscriptionMgrUrl
,Users.UserName AS SubscriptionOwner
,Subscriptions.Description AS SubscriptionDescription
,Subscriptions.LastStatus
,Subscriptions.LastRunTime
FROM [dbo].[ReportSchedule]
INNER JOIN [dbo].[Schedule]
ON ReportSchedule.ScheduleID = Schedule.ScheduleID
INNER JOIN [dbo].[Catalog]
ON ReportSchedule.ReportID = Catalog.ItemID
INNER JOIN [dbo].[Subscriptions]
ON ReportSchedule.SubscriptionID = Subscriptions.SubscriptionID
INNER JOIN [dbo].[Users]
ON Subscriptions.OwnerID = Users.UserID
WHERE ((Subscriptions.DataSettings IS NULL AND Subscriptions.LastStatus LIKE 'Failure%') -- handle standard subscription errors
OR (Subscriptions.DataSettings IS NOT NULL AND RIGHT(Subscriptions.LastStatus, 11) <> '; 0 errors.'))
and Subscriptions.LastRunTime > dateadd(day, -31, getdate())



SQL Server 2014 Hosting - HostForLIFE.eu :: Script the SQL Server Agent Operators

clock October 22, 2015 23:56 by author Peter

As a part of the Disaster recovery procedures, I wished to script out each server object that we had created. This enclosed SQL Server jobs, logins, operators, coupled servers and proxies. i used to be able to script out everything but the SQL Server Agent operators:

USE msdb
set nocount on;

create table #tbl (
id int not null,
name sysname not null,
enabled tinyint not null,
email_address nvarchar(100) null,
last_email_date int not null,
last_email_time int not null,
pager_address nvarchar(100) null,
last_pager_date int not null,
last_pager_time int not null,
weekday_pager_start_time int not null,
weekday_pager_end_time int not null,
Saturday_pager_start_time int not null,
Saturday_pager_end_time int not null,
Sunday_pager_start_time int not null,
Sunday_pager_end_time int not null,
pager_days tinyint not null,
netsend_address nvarchar(100) null,
last_netsend_date int not null,
last_netsend_time int not null,
category_name sysname null);

insert into #tbl
  EXEC sp_help_operator;

select 'USE msdb;' + char(13) + char(10) + 'if exists (select * from dbo.sysoperators where name =' + quotename(name, char(39)) + ') ' + char(13) + char(10) +
'exec sp_add_operator ' +
'@name = ' + quotename(name, char(39)) + ', ' +
'@enabled = ' + cast (enabled as char(1)) + ', ' +
'@email_address = ' + quotename(email_address, char(39)) + ', ' +
case
when pager_address is not null then '@pager_address = ' + quotename(pager_address, char(39)) + ', '
else ''
end +
'@weekday_pager_start_time = ' + ltrim(str(weekday_pager_start_time)) + ', ' +
'@weekday_pager_end_time = ' + ltrim(str(weekday_pager_end_time)) + ', ' +
'@Saturday_pager_start_time = ' + ltrim(str(Saturday_pager_start_time)) + ', ' +
'@Saturday_pager_end_time = ' + ltrim(str(Saturday_pager_end_time)) + ', ' +
'@Sunday_pager_start_time = ' + ltrim(str(Sunday_pager_start_time)) + ', ' +
'@Sunday_pager_end_time = ' + ltrim(str(Sunday_pager_end_time)) + ', ' +
'@pager_days = ' + cast(pager_days as varchar(3)) +
case
when netsend_address is not null then ', @netsend_address = ' + quotename(netsend_address, char(39))
else ''
end +
case
when category_name != '[Uncategorized]' then ', @category_name = ' + category_name
else ''
end +
'; ' + char(13) + char(10) + 'go'
from #tbl order by id;

drop table #tbl;

I hope it works for you!

HostForLIFE.eu SQL Server 2014 Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.



About HostForLIFE.eu

HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.

We have offered the latest Windows 2016 Hosting, ASP.NET Core 2.2.1 Hosting, ASP.NET MVC 6 Hosting and SQL 2017 Hosting.


Tag cloud

Sign in