European Windows 2012 Hosting BLOG

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

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 <h1> (Heading 1) tag should be the most important heading on your page. <h2> should be next and so forth, like an outline. The <p> should separate paragraphs. Addresses should be indicated with <address> and lists with <ul> (unordered) or <ol> (ordered). Links created with the <a> 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.



SQL Server 2014 Hosting - HostForLIFE.eu :: How to Use Trigger in SQL Server 2014?

clock October 20, 2015 09:29 by author Peter

A trigger is a special kind of stored procedure that automatically executes when an event occurs in the database server. DML triggers execute when a user tries to modify data through a data manipulation language (DML) event. DML events are INSERT, UPDATE, or DELETE statements on a table or view. These triggers fire when any valid event is fired, regardless of whether or not any table rows are affected.

There are three types of triggers. Basically triggers are classified in to two main type

  • Insert Of Trigger.
  • After Trigger.


This After Trigger run after an insert, update, or delete on table. They are not support view.
So we can say that after trigger also classified in to three types:-

  • AFTER INSERT trigger.
  • AFTER UPDATE trigger.
  • AFTER DELETE trigger.

Insert Trigger
Whenever a row is inserted in the Customers Table, the following trigger will be executed. The newly inserted record is available in the INSERTED table. The following Trigger is fetching the CustomerId of the inserted record and the fetched value is inserted in the CustomerLogs table. Now, write the following code:
CREATE TRIGGER [dbo].[Customer_INSERT]
ON [dbo].[Customers]
AFTER INSERT
AS
BEGIN
SET NOCOUNT ON;
DECLARE @CustomerId INT
SELECT @CustomerId = INSERTED.CustomerId      
FROM INSERTED
INSERT INTO CustomerLogs
VALUES(@CustomerId, 'Inserted')
END


Update Trigger
In the below code is an example of an After Update Trigger. Now write the following code:
CREATE TRIGGER [dbo].[Customer_UPDATE]
ON [dbo].[Customers]
AFTER UPDATE
AS
BEGIN
SET NOCOUNT ON;

DECLARE @CustomerId INT
DECLARE @Action VARCHAR(50)

SELECT @CustomerId = INSERTED.CustomerId      
FROM INSERTED

IF UPDATE(Name)
BEGIN
      SET @Action = 'Updated Name'
END

IF UPDATE(Country)
BEGIN
      SET @Action = 'Updated Country'
END

INSERT INTO CustomerLogs
VALUES(@CustomerId, @Action)
END

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 Access SSRS with Fully Qualified Domain Name?

clock October 13, 2015 11:24 by author Peter

If you installed SQL Server reporting Services (SSRS) on a server in a domain and you utilize a website user to start out the service and did not perform any further configuration, then you likely will only access the Report Manager using an IP and not the fully Qualified domain name (FQDN) of the server (if an SPN isn't set).

If you are trying to use the fully Qualified domain name to access reporting services then you may likely be prompted for username password several times ending with an empty page.

In order to be able to access reporting Services using FQDN you may need to perform the subsequent actions:
1. Register a Service Principal Name (SPN) for the Domain User Account that Runs SSRS
Please look at the following example:
sample computer name: testssrs01
sample domain: example.com
sample domain account: example\ssrsuser


Next, on the Domain Controller Server in a Command Prompt with Elevated Rights, you can Run as Administrator:
Example 1:
If SSRS are on port 80 (no need to specify 80 as it is the default http port):
Setspn -s http/testssrs01.example.com example\ssrsuser

Example 2:
If SSRS are on any other port (i.e. 2430):
Setspn -s http/testssrs01.example.com:2430 example\ssrsuser

2. Edit the RsReportServer.config File
On the Reporting Services server, in the virtual directory of SSRS, edit the "RsReportServer.config" file and locate the authenticationtypes section. Then add /rswindowsnegotiate as the first entry in the authenticationtypes section.

This above step will actually enable NTLM.

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.



AngularJS Hosting - HostForLIFE.eu :: User Validation with Bootstrap in AngularJS

clock October 8, 2015 12:11 by author Peter

AngularJS forms and controls can validate input data. AngularJS forms and controls can provide validation services, and notify users of invalid input. In this tutorial, we will learn how to perform user validation with bootstrap in AngularJS.

HTML code
var app = angular.module('myapp', ['UserValidation']); 
myappCtrl = function($scope) { 
$scope.formAllGood = function () { 
return ($scope.usernameGood && $scope.passwordGood && $scope.passwordCGood) 




angular.module('UserValidation', []).directive('validUsername', function () { 
return { 
require: 'ngModel', 
link: function (scope, elm, attrs, ctrl) { 
ctrl.$parsers.unshift(function (viewValue) { 
    // Any way to read the results of a "required" angular validator here? 
    var isBlank = viewValue === '' 
    var invalidChars = !isBlank && !/^[A-z0-9]+$/.test(viewValue) 
    var invalidLen = !isBlank && !invalidChars && (viewValue.length < 5 || viewValue.length > 20) 
    ctrl.$setValidity('isBlank', !isBlank) 
    ctrl.$setValidity('invalidChars', !invalidChars) 
    ctrl.$setValidity('invalidLen', !invalidLen) 
    scope.usernameGood = !isBlank && !invalidChars && !invalidLen 

}) 


}).directive('validPassword', function () { 
return { 
require: 'ngModel', 
link: function (scope, elm, attrs, ctrl) { 
ctrl.$parsers.unshift(function (viewValue) { 
    var isBlank = viewValue === '' 
    var invalidLen = !isBlank && (viewValue.length < 8 || viewValue.length > 20) 
    var isWeak = !isBlank && !invalidLen && !/(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z])/.test(viewValue) 
    ctrl.$setValidity('isBlank', !isBlank) 
    ctrl.$setValidity('isWeak', !isWeak) 
    ctrl.$setValidity('invalidLen', !invalidLen) 
    scope.passwordGood = !isBlank && !isWeak && !invalidLen 

}) 


}).directive('validPasswordC', function () { 
return { 
require: 'ngModel', 
link: function (scope, elm, attrs, ctrl) { 
ctrl.$parsers.unshift(function (viewValue, $scope) { 
    var isBlank = viewValue === '' 
    var noMatch = viewValue != scope.myform.password.$viewValue 
    ctrl.$setValidity('isBlank', !isBlank) 
    ctrl.$setValidity('noMatch', !noMatch) 
    scope.passwordCGood = !isBlank && !noMatch 
}) 


}) 

JAVASCRIPT Code

var app = angular.module('myapp', ['UserValidation']); 

myappCtrl = function($scope) { 
$scope.formAllGood = function () { 
return ($scope.usernameGood && $scope.passwordGood && $scope.passwordCGood) 




angular.module('UserValidation', []).directive('validUsername', function () { 
return { 
require: 'ngModel', 
link: function (scope, elm, attrs, ctrl) { 
ctrl.$parsers.unshift(function (viewValue) { 
    // Any way to read the results of a "required" angular validator here? 
    var isBlank = viewValue === '' 
    var invalidChars = !isBlank && !/^[A-z0-9]+$/.test(viewValue) 
    var invalidLen = !isBlank && !invalidChars && (viewValue.length < 5 || viewValue.length > 20) 
    ctrl.$setValidity('isBlank', !isBlank) 
    ctrl.$setValidity('invalidChars', !invalidChars) 
    ctrl.$setValidity('invalidLen', !invalidLen) 
    scope.usernameGood = !isBlank && !invalidChars && !invalidLen 

}) 


}).directive('validPassword', function () { 
return { 
require: 'ngModel', 
link: function (scope, elm, attrs, ctrl) { 
ctrl.$parsers.unshift(function (viewValue) { 
    var isBlank = viewValue === '' 
    var invalidLen = !isBlank && (viewValue.length < 8 || viewValue.length > 20) 
    var isWeak = !isBlank && !invalidLen && !/(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z])/.test(viewValue) 
    ctrl.$setValidity('isBlank', !isBlank) 
    ctrl.$setValidity('isWeak', !isWeak) 
    ctrl.$setValidity('invalidLen', !invalidLen) 
    scope.passwordGood = !isBlank && !isWeak && !invalidLen 

}) 


}).directive('validPasswordC', function () { 
return { 
require: 'ngModel', 
link: function (scope, elm, attrs, ctrl) { 
ctrl.$parsers.unshift(function (viewValue, $scope) { 
    var isBlank = viewValue === '' 
    var noMatch = viewValue != scope.myform.password.$viewValue 
    ctrl.$setValidity('isBlank', !isBlank) 
    ctrl.$setValidity('noMatch', !noMatch) 
    scope.passwordCGood = !isBlank && !noMatch 
}) 


}) 


If you fill with the wrong detail then it'll give the error like the following picture:

HostForLIFE.eu AngularJS 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