Windows 2012 Hosting - MVC 6 and SQL 2014 BLOG

Tutorial and Articles about Windows Hosting, SQL Hosting, MVC Hosting, and Silverlight Hosting

SQL SERVER 2014 Hosting - ASPHostPortal :: Automatic SQL Server Backup Utility using Sqlserver Agent

clock March 23, 2015 08:22 by author Mark

Automatic SQL Server Backup Utility using Sqlserver Agent

It is a sample C# (Visual Studio) application for Automatic Sql server Backup Utility using sqlserveragent. I have used SQL-DMO dll. This article will show you how to create a automatic backup in Sql server.
This code should work on any PC use VB.NET and installed SQL Server(any edition or Client Components for SQL Server.
SQLDMO (Which installed always bt MS SQL Serveror MS SQL Server Client Tools
To do:

  • First enter your SQL Server username and password on corresponding Text Box.
  • Set backup Start date & Backup Time
  • After Finishing this then please check manually it will working or not
  • Manual working procedure:
    • Run Sql sever enterprise Manager
    • Select management Option
    • Open Sql server agent
    • Open Jobs window
    • Check whether job item exist or not
    • Right click on newly created job item then, we will get one
    • Popup menu, then select start job
    • After finish the job then check folder "D:\backup" bkp file created or not

Add reference to SQL-DMO dll

You can do this by right clicking the project in Solution Explorer, then selecting 'Add Reference', COM components and the latest version of "Microsoft SQLDMO Object Library".

Available Server

public void dIsplayServerList(ComboBox cboListName)
{
    try
    {
        SQLDMO.Application oSQLServerDMOApp = new SQLDMO.Application();
        Info.informationLayer info = new Info.informationLayer();           
        SQLDMO.NameList oNameList;
        oNameList = oSQLServerDMOApp.ListAvailableSQLServers();
        for (int intIndex = 0; intIndex <= oNameList.Count - 1; intIndex++)
        {
            if (oNameList.Item(intIndex as object) != null)
            {
                cboListName.Items.Add(oNameList.Item(intIndex).ToString());
            }
        }
        if (cboListName.Items.Count > 0) cboListName.SelectedIndex = 0;
        else cboListName.Text = "(Local)";
        }
    catch
    {
}
}

Available databases

public void dIsplayDatabases(ComboBox cboDatabase,Info.informationLayer info)
{
    try
    {
        SQLDMO._SQLServer SQLServer = new SQLDMO.SQLServerClass();
        cboDatabase.Items.Clear();
        SQLServer.Connect(info.strServerName,info.strLoginName,info.strPwd);
        foreach (SQLDMO.Database db in SQLServer.Databases)
        {
            if (db.Name != null)
                cboDatabase.Items.Add(db.Name);
        }
        cboDatabase.Sorted = true;
        if (cboDatabase.Items.Count == 0)cboDatabase.Text = "<No databases found>";
    }
    catch (Exception err)
    {
       info.ErrorMessageDataLayer = err.Message;
    }
}
Create Job on Server Agent:
public void CreateJob_Sql(Info.informationLayer info)
{
    try
    {
        SQLDMO._SQLServer SQLServer = new SQLDMO.SQLServerClass();
        SQLDMO.Job SQLJob = new SQLDMO.Job();
        SQLDMO.JobSchedule SQLSchedule = new SQLDMO.JobSchedule();
        SQLServer.Connect(info.strServerName, info.strLoginName, info.strPwd);
        switch (SQLServer.JobServer.Status)
        {
            case SQLDMO_SVCSTATUS_TYPE.SQLDMOSvc_Stopped:
            SQLServer.JobServer.Start();
            SQLServer.JobServer.AutoStart = true;
            break;
        }
        SQLJob.Name = info.strDatabaseName;
        SQLJob.Description = "Check and Backup" + info.strDatabaseName;
        SQLServer.JobServer.Jobs.Add(SQLJob);
        SQLJob.Category = "Database Maintenance";
        SQLDMO.JobStep aJobStep = new SQLDMO.JobStep();
        aJobStep.Name = "Step 2: Backup the Database";
        aJobStep.StepID = 1;
        aJobStep.DatabaseName = info.strDatabaseName;
        aJobStep.SubSystem = "TSQL";
        //------>>> If BackUp Folder is Not Found then create BackUp Folder                
        string   DirectoryName = "D:\\BackUp";
        if (Directory.Exists(DirectoryName)==false)
        {
            System.IO.Directory.CreateDirectory(DirectoryName);
        }
        //------>>>
        string sExt;
        sExt="EXEC master.dbo.xp_sqlmaint '-S " + info.strServerName + " -U " + info.strLoginName + " -P " + info.strPwd + "  -D " + info.strDatabaseName + " -CkDB -CkAl -CkCat -BkUpMedia DISK -BkUpDB D:\\Backup  -BkExt BAK -DelBkUps 2weeks -BkUpOnlyIfClean -Rpt D:\\Backup\\BackDB_Checks.txt'";
        aJobStep.Command = sExt;
        aJobStep.OnSuccessAction = SQLDMO_JOBSTEPACTION_TYPE.SQLDMOJobStepAction_QuitWithSuccess;
        aJobStep.OnFailAction = SQLDMO_JOBSTEPACTION_TYPE.SQLDMOJobStepAction_QuitWithFailure;
        SQLJob.JobSteps.Add(aJobStep);
        SQLJob.ApplyToTargetServer(info.strServerName);
        aJobStep.DoAlter();
        SQLJob.Refresh();
        aJobStep.Refresh();
    }
    catch (Exception Err)
    {
        info.ErrorMessageDataLayer = Err.Message;
    }
}

Create Job shedule on  server Agent:

public void CreateShedule_Sql(Info.informationLayer info)
{
    try
    {
        //it will take bkp every week 2 day
        SQLDMO.Job SQLJob = new SQLDMO.Job();
        SQLDMO._SQLServer SQLServer = new SQLDMO.SQLServerClass();
        SQLDMO.JobSchedule SQLSchedule = new SQLDMO.JobSchedule();
        SQLServer.Connect(info.strServerName, info.strLoginName, info.strPwd);
        SQLJob = SQLServer.JobServer.Jobs.Item(info.strDatabaseName);
        // create a new JobSchedule object
        SQLSchedule.Name = "Weekly Backup";
        SQLSchedule.Schedule.FrequencyType = SQLDMO.SQLDMO_FREQUENCY_TYPE.SQLDMOFreq_Weekly;
        SQLSchedule.Schedule.FrequencyInterval = 2;
        SQLSchedule.Schedule.FrequencyRecurrenceFactor = 2;
        // // start on Mar22, 2015 - at 12.55
        SQLSchedule.Schedule.ActiveStartDate = info.intStartDate;
        SQLSchedule.Schedule.ActiveStartTimeOfDay = info.intStartTime;
        ////  this schedule has no end time or end date
        SQLSchedule.Schedule.ActiveEndDate = 99991231;
        SQLSchedule.Schedule.ActiveEndTimeOfDay = 235959;
        ////  add the schedule to the Job
        SQLJob.BeginAlter();
        SQLJob.JobSchedules.Add(SQLSchedule);
        SQLJob.DoAlter();
        //SQLJob.JobSchedules.Refresh();
        info.ErrorMessageDataLayer = "New Sql Job [Databasename= " + info.strDatabaseName + " ]Sucessfully Created.  ";
    }
    catch (Exception err)
    {
        info.ErrorMessageDataLayer = err.Message;
    }
}

Syntax (SQL Server)

xp_sqlmaint 'switch_string'
[
    [-S server_name[\instance_name]]
    [-U login_ID [-P password]]
    {
        [ -D database_name | -PlanName name | -PlanID guid ]
        [-Rpt text_file]
        [-To operator_name]
        [-HtmlRpt html_file [-DelHtmlRpt <time_period>] ]
        [-RmUnusedSpace threshold_percent free_percent]
        [-CkDB | -CkDBNoIdx]
        [-CkAl | -CkAlNoIdx]
        [-CkCat]
        [-UpdOptiStats sample_percent]
        [-RebldIdx free_space]
        [-WriteHistory]
        [
            {-BkUpDB [backup_path] | -BkUpLog [backup_path] }
            {-BkUpMedia
                {DISK [    [-DelBkUps <time_period>]
                            [-CrBkSubDir ] [ -UseDefDir ]
                         ]
                | TAPE
                }
            }
            [-BkUpOnlyIfClean]
            [-VrfyBackup]
        ]
    }
]
time_period
number[minutes | hours | days | weeks | months]

Syntax (SQL Server)

sqlmaint
[-?] |
[
    [-S server]
    [-U login_ID [-P password]]
    {
        [ -D database_name | -PlanName name | -PlanID guid ]
        [-Rpt text_file [-DelTxtRpt <time_period>] ]
        [-To operator_name]
        [-HtmlRpt html_file [-DelHtmlRpt <time_period>] ]
        [-RmUnusedSpace threshold_percent free_percent]
        [-CkDB | -CkDBNoIdx]
        [-CkAl | -CkAlNoIdx]
        [-CkTxtAl]
        [-CkCat]
        [-UpdSts]
        [-UpdOptiStats sample_percent]
        [-RebldIdx free_space]
        [-WriteHistory]
        [
            {-BkUpDB [backup_path] | -BkUpLog [backup_path] }
            {-BkUpMedia
                {DISK [    [-DelBkUps <time_period>]
                            [-CrBkSubDir ] [ -UseDefDir ]
                         ]
                | TAPE
                }
            }
            [-BkUpOnlyIfClean]
            [-VrfyBackup]
        ]
    }
]

Best SQL 2014 Hosting Recommendation

ASPHostPortal.com

ASPHostPortal.com provides our customers with Plesk Panel, one of the most popular and stable control panels for Windows hosting, as free. You could also see the latest .NET framework, a crazy amount of functionality as well as Large disk space, bandwidth, MSSQL databases and more. All those give people the convenience to build up a powerful site in Windows server. We offers SQL 2014 hosting starts from $5/month only. We also guarantees 30 days money back and guarantee 99.9% uptime. If you need a reliable affordable SQL 2014 Hosting, we should be your best choice.



SQL Server 2014 Hosting with ASPHostPortal.com :: How to Restart an Interrupted SQL Server Database Restore

clock August 23, 2014 09:53 by author Kenny

SQL Server is Microsoft's relational database management system (RDBMS). It is a full-featured databse primarily designed to compete against competitors Oracle Database (DB) and MySQL.

Like all major RBDMS, SQL Server supports ANSI SQL, the standard SQL language. However, SQL Server also contains T-SQL, its own SQL implemention. SQL Server Management Studio (SSMS) (previously known as Enterprise Manager) is SQL Server’s main interface tool, and it supports 32-bit and 64-bit environments.

In this article, we will tell you about how to restart an interrupted SQL Server Database Restore.
Have you ever restored a large database on a Failover Cluster Production Server and while the restore was in progress, due to network failure, the restore failed? Once the SQL Server came up on the other node all the databases came up, except for the database which you were restoring prior to the failover. In this tip we will take a look at the command RESTORE DATABASE...WITH RESTART to see how this command can be helpful during such scenarios.

Here is the solution

The RESTORE DATABASE...WITH RESTART command is a very useful command which is available in SQL Server 2005 and higher versions. A Database Administrator can use this command to finish restoring an interrupted database restore operation.

In the below snippet you can see that ProductDB is in a (Restoring...) state once the SQL Server came online after the unexpected failure.

During such scenarios one can execute the RESTORE DATABASE...WITH RESTART command to successfully complete the database restore operation.

Below are two commands.  The first gets a list of the backups on the file and the second does the actual restore with the restart option.

-- get backup information from backup file
RESTORE FILELISTONLY
FROM DISK ='C:\DBBackups\ProductDB.bak'
GO

-- restore the database
RESTORE DATABASE ProductDB
FROM DISK ='C:\DBBackups\ProductDB.bak'
WITH RESTART
GO

Below you can see that after running the RESTORE DATABASE...WITH RESTART command the database was successfully restored allowing user connectivity.



SQL 2012 Hosting with ASPHostPortal.com:: How to Handle Deadlock in SQL Server with Script

clock June 13, 2014 09:30 by author Ben

A deadlock is an inevitable situation in the RDBMS architecture and very common in high-volume OLTP environments. A deadlock occurs when two (or more) processes attempt to access a resource that the other process holds a lock on. Because each process has a request for another resource, neither process can be completed. When a deadlock is detected, SQL Server rolls back the command that has the least processing time and returns error message 1205 to the client application. This error is not fatal and may not cause the batch to be terminated.

Here is the simple script to handle deadlock monitoring using T-SQL code

CREATE EVENT SESSION [Deadlock_Monitor] ON SERVER
 ADD EVENT sqlserver.xml_deadlock_report
 ADD TARGET package0.event_file(SET filename=N'C:\Temp\Deadlock_Monitor.xel')
 WITH (MAX_MEMORY=4096 KB,EVENT_RETENTION_MODE=ALLOW_SINGLE_EVENT_LOSS,
 MAX_DISPATCH_LATENCY=30 SECONDS,MAX_EVENT_SIZE=0 KB,MEMORY_PARTITION_MODE=NONE,
 TRACK_CAUSALITY=OFF,STARTUP_STATE=ON)
 GO

For another way, there is two method with script to handle deadlock in SQL Server, such as:

  • method 1

/*--
-- ,,
-- ,,
-- ,,,
-- 2004.4--
--
 exec p_lockinfo
--*/
create proc p_lockinfo
    @kill_lock_spid bit=1, --,1 , 0
    @show_spid_if_nolock bit=1 --,,1 ,0
as
    declare @count int,@s nvarchar(1000),@i int
    select id=identity(int,1,1),,
        ID=spid,ID=kpid,ID=blocked,ID=dbid,
        =db_name(dbid),ID=uid,=loginame,CPU=cpu,
        =login_time,=open_tran, =status,
        =hostname,=program_name,ID=hostprocess,
        =nt_domain,=net_address
    into #t from(
        select ='',
            spid,kpid,a.blocked,dbid,uid,loginame,cpu,login_time,open_tran,
            status,hostname,program_name,hostprocess,nt_domain,net_address,
            s1=a.spid,s2=0
        from master..sysprocesses a join (
        select blocked from master..sysprocesses group by blocked
        )b on a.spid=b.blocked where a.blocked=0
        union all
        select '|__>',
            spid,kpid,blocked,dbid,uid,loginame,cpu,login_time,open_tran,
            status,hostname,program_name,hostprocess,nt_domain,net_address,
            s1=blocked,s2=1
        from master..sysprocesses a where blocked<>0
        )a order by s1,s2

    select @count=@@rowcount,@i=1

    if @count=0 and @show_spid_if_nolock=1
    begin
        insert #t
        select ='',
            spid,kpid,blocked,dbid,db_name(dbid),uid,loginame,cpu,login_time,
            open_tran,status,hostname,program_name,hostprocess,nt_domain,net_address
        from master..sysprocesses
        set @count=@@rowcount
    end

    if @count>0
    begin
        create table #t1(id int identity(1,1),a nvarchar(30),b Int,EventInfo nvarchar(255))
        if @kill_lock_spid=1
            begin
                declare @spid varchar(10),@ varchar(10)
                while @i<[email protected]
                begin
                    select @spid=ID,@= from #t where [email protected]
                    insert #t1 exec('dbcc inputbuffer([email protected]+')')
                    if @='' exec('kill [email protected])
                    set @[email protected]+1
                end
            end
        else
            while @i<[email protected]
            begin
                select @s='dbcc inputbuffer('+cast(ID as varchar)+')' from #t where [email protected]
                insert #t1 exec(@s)
                set @[email protected]+1
            end
        select a.*,SQL=b.EventInfo
        from #t a join #t1 b on a.id=b.id
    end
go

  • method 2


SELECT
request_session_id as Spid,
Coalesce(s.name + '.' + o.name + isnull('.' + i.name,''),
s2.name + '.' + o2.name,
db.name) AS Object,
l.resource_type as Type,
request_mode as Mode,
request_status as Status
FROM sys.dm_tran_locks l
LEFT JOIN sys.partitions p
ON l.resource_associated_entity_id = p.hobt_id
LEFT JOIN sys.indexes i
ON p.object_id = i.object_id
AND p.index_id = i.index_id
LEFT JOIN sys.objects o
ON p.object_id = o.object_id
LEFT JOIN sys.schemas s
ON o.schema_id = s.schema_id
LEFT JOIN sys.objects o2
ON l.resource_associated_entity_id = o2.object_id
LEFT JOIN sys.schemas s2
ON o2.schema_id = s2.schema_id
LEFT JOIN sys.databases db
ON l.resource_database_id = db.database_id
WHERE resource_database_id = DB_ID()
ORDER BY Spid, Object, CASE l.resource_type
When 'database' Then 1
when 'object' then 2
when 'page' then 3
when 'key' then 4
Else 5 end


SQL Server 2012 Hosting is Here with FREE Trial!

Start your FREE Trial SQL 2012 Hosting hosting with us and get professional web hosting support! If the service does not meet your expectations simply cancel before the end of the free trial period. Risk FREE! Why wait longer?

You can start from as low as $5.00/month to start hosting your SQL 2012 on our environment. If you do not have a domain name, please do not worry as we will give you one FREE domain name (worth $14.99/year) if you register for any of our hosting plans for 12 months service(*). We will do our best to help you create your first web presence on the internet and we will continuously support the growth of your business.

 



mojoPortal Hosting - How to Recover Password Login on Your mojoPortal Site

clock April 29, 2014 07:54 by author Ben

mojoPortal is another open source CMS option based upon the .NET framework. It has a very active developer group and is consistently being updated. While it is free to download and use, there are a number of commercial add-ons that are used to help fund the project. When it comes to developing your own applications, many people prefer mojoPortal because it can act as a starter kit for advanced .NET sites or portals.

mojoPortal is also considered to be very strong as a standalone CMS. It is easy to learn and very simple to use. It includes a variety of different tools such as blogs, photo galleries, chat, newsletters, pools, forums, and much more. It also has a very strong community which makes troubleshooting extremely simple.

Here is the tutorial how to recover password login on your mojoPortal site :

However, in order to use this feature you require login e-mail which you used either at the time of installation or while updating the site later on.

Sometimes, you will forget password but your login e-mail id will be the default provided by the installer – [email protected]

In such a scenario, you need to dig deep into the database to find out the password as mentioned below

  1. Open SQL Server 2008 / 2012
  2. You will view a dialog named – Connect to Server
  3. Provide the database name, database username and password which you provided at the time of mojoportal installation process.
  4. If you installed MojoPortal through Web App Gallery from within WebsitePanel then you need to search for “user.config” file from the file manager and fetch the required credentials.
  5. If the provided credentials are correct then you will be logged into SQL Server. Locate your database from the navigation panel located on the left hand side.
  6. Expand the database name, then Tables and locate the table name – dbo.mp_Users
  7. Right click on the above mentioned table and select the option – Select Top 1000 Rows
  8. SQL Server will display the list of entries under each column. By default, it will only show details of Admin user. However, you will view more entries if your site is bit old and users have registered on the site.
  9. In order to view the password of admin user, you need to scroll horizontally until you see the column name – Pwd.


It is to be noted that MojoPortal displays passwords as such without any kind of encryption. Hence, you should use very strong password for the database, FTP and administrator user account.



Reporting Services Hosting with ASPHostPortal :: Integrating Reporting Services Into a Web Application

clock April 4, 2014 13:12 by author Kenny

With Visual Studio you can be easier to integrate SQL Reporting Services into ASP.NET web applications. Now, i will explain about how to integrate Report Services into a web application using Visual Studio.

First, you must create a new project in Visual Studio, in the ASP.NET code, you will need to delete (or change) this line:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Next replace any existing code between the <form> tags with the below code:
<table style="vertical-align: bottom; border-width: 0px; margin-top: 0px;
   margin-bottom: 0px; width: 100%; height: 100%; padding: 0px,0px,0px,0px;"
   cellspacing="0" cellpadding="0">
    <tr>
        <td>
            HEADER
        </td>
    </tr>
    <tr>
        <td>
            <div style="border-top: black 1px solid;
                background-color: #ece9d8; border-bottom-width: 1px;
                border-bottom-color: #d4d0c8; padding-bottom: 10px;">
                Custom Controls
            </div>
       </td>
    </tr>
    <tr>
        <td style="height: 100%;">
            <%-- This is where the ReportViewer control will go. --%>
        </td>
    </tr>
</table>


Switch to the “Design” view since it is now time to add the ReportViewer control.
In the “Data” section within the Toolbox, drag the ReportViewer control onto the last row of your table, which should be taking up most of the page. Next you want to set the control’s properties so that it points to the right server and the right report. Under properties, go to the “Server Report” section. Right above the section you should see a property called “ProcessingMode”. In most cases you are going to want use an instance of a Report Server. So for the purposes of this tutorial, set this property to “Remote”, even if the Report Server instance is on the same computer as your web app. Next, you want to set the “ServerReport” settings.

First, type in address of the Report server in the “ReportSeverUrl” field.
The syntax is:
http:// NameOfServer / reportserver
i.e. http://ServerOne/reportserver

Next type in the location of the report in the “ReportPath” field.
i.e. /MyReports/TheReport

The location is easy to know since it is the same path structure that you see in the Report Manager. Also, always be sure the put a forward slash first before the actual path.

Unless you want the ReportViewer to be an absolute size, go ahead and set the height and width settings under the “Layout” section to be 100%. The ReportViewer will by default show controls to set the parameters for the report. These often look a little ugly, and I would recommend most developers to create their own parameter controls. This can be done in the control bar row of the template provided above. To get rid of the ReportViewer’s parameter controls set the “ShowParameterPrompts” in the properties underneath “Appearance” to false. In, the next section I’ll show how you can set the report parameters with your own code.

Those should be all the settings you need to make for the ReportViewer to display correctly, unless your version of Visual Studio has other default settings. Double check to make sure the ASP.NET looks similar to this code:
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Height="100%"
    ProcessingMode="Remote" ShowParameterPrompts="False" Width="100%">
    <ServerReport ReportPath="/MyReports/TheReport" />
</rsweb:ReportViewer>

Now, the report is ready to be processed. You can go ahead and preview your website and the report should generate just fine.



FREE Trial SQL 2012 Hosting - with ASPHostPortal.com :: New Security Features SQL Server 2012

clock March 18, 2014 12:12 by author Diego

Microsoft SQL Server 2012 continues this trend with an extensive collection of new security features and enhancements. These enhancements not only help organizations to improve access controls to data, but also to achieve the highest level of data protection and compliance. Also, these features help make SQL Server arguably the most robust common database platform from a security perspective, with less vulnerability and fewer security patches needed to maintain the system.

SQL Server 2012 has many new security features, and three of the bigger new features are: Default Schema for Windows Groups, Audit enhancements, and User-Defined Server Roles.

Default schema for Windows groups
A database schema can now be tied to a Windows Group rather than an individual user in order to increase database compliance.  This makes it easier to administer database schemas, decreases the complexity of database schema management through individual Windows users, prevents errors of assigning a schema to the wrong user when a user changes groups, avoids unnecessary implicit schema creation, and by reducing the chances of choosing the wrong schema then it greatly reduces the chance of query errors.

Before SQL Server 2012 was introduced, it was not possible to specify the default schema for Windows groups. As a result, when the user getting access through Windows group membership created database objects such as a table or view inside a database, SQL Server automatically created a separate user (mapped to the admin account) and a schema with the same name in the database. Because of this security manageability issue, we end up having hundreds of users and schemas inside databases, which caused administrative challenges and is a managerial nightmare for administrators. Hence, SQL Server community requested a fix for this security issue via the Microsoft Connect site.

Luckily, SQL Server 2012 addresses this security issue by allowing us to assign a default schema for Windows Groups, which helps organizations simplify their database schema administration.

The following Transact SQL (T-SQL) demonstrates the process of assigning the default schema for Windows Group:

-- Creating Default Schema "ProdAdmins" for Windows Group "MyDomain\ProdDBAs"
CREATE SCHEMA [ProdAdmins] AUTHORIZATION [MyDomain\ProdDBAs]
GO


-- Set Default Schema for Windows Group "MyDomain\ProdDBAs"
ALTER USER [MyDomain\ProdDBAs] WITH DEFAULT_SCHEMA=[ProdAdmins]
GO

Audit Enhancements
Server and database audit specification objects found in SQL Server 2008 and SQL Server 2008 R2 are the most useful features of SQL Server and help the organization meet various regulatory compliance requirements. The problem with these auditing features is that they were only in the enterprise edition.

Fortunately, the server level audit specification features are now supported by all versions of SQL Server 2012. Audit specification features of SQL Server 2012 are more resilient to failures with writing to the audit log, and it is possible to limit the number of audit log files without rolling over. SQL Server 2012 audit specification features also support user-defined groups, which means we can now write audited events to the audit log by using sp_audit_write (Transact-SQL) procedure. Finally, SQL Server 2012 supports the ability to filter the audit events and include new audited groups to monitor contained database users.

User-Defined Server Roles
User-Defined Server Roles increase flexibility, manageability, and facilitates compliance towards better separation of duties.  It allows creation of new server roles to suit different organizations that separate multiple administrators according to roles.  Roles can also be nested to allow more flexibility in mapping to hierarchical structures in organizations.  It also helps prevent organizations from using sysadmin for database administration. We can use CREATE SERVER ROLE, ALTER SERVER ROLE and DROP SERVER ROLE Transact-SQL statements to create, alter and drop user-defined server roles. This is demonstrated as follows:

-- Creating user-defined roles
CREATE SERVER ROLE [JuniorDBA]


-- Granting server-wide permissions

GRANT CREATE ANY DATABASE TO [JuniorDBA]

-- Adding members to user-defined roles
ALTER SERVER ROLE [JuniorDBA]
ADD MEMBER [Domain\JuniorDBA_Group1]
ALTER SERVER ROLE [JuniorDBA]
ADD MEMBER [Domain\JuniorDBA_Group1]

-- Making user-defined role member of fixed server role ALTER SERVER ROLE [processadmin]
ADD MEMBER [JuniorDBA]


-- Dropping user-defined roles
DROP SERVER ROLE [JuniorDBA]



About ASPHostPortal.com

We’re a company that works differently to most. Value is what we output and help our customers achieve, not how much money we put in the bank. It’s not because we are altruistic. It’s based on an even simpler principle. "Do good things, and good things will come to you".

Success for us is something that is continually experienced, not something that is reached. For us it is all about the experience – more than the journey. Life is a continual experience. We see the Internet as being an incredible amplifier to the experience of life for all of us. It can help humanity come together to explode in knowledge exploration and discussion. It is continual enlightenment of new ideas, experiences, and passions


Author Link


Corporate Address (Location)

ASPHostPortal
170 W 56th Street, Suite 121
New York, NY 10019
United States

Sign in