SQL SERVER – Retrieve Information of SQL Server Agent Jobs

Comments Off

sp_help_job returns information about jobs that are used by SQLServerAgent service to perform automated activities in SQL Server.

EXEC MSDB.DBO.SP_HELP_JOB

SQL SERVER – 2005 – List all the database

Comments Off

List all the database on SQL Servers.

SQL SERVER 2005 System Procedures

EXEC sp_databases
EXEC sp_helpdb

SQL 2000 Method still works in SQL Server 2005

SELECT name FROM sys.databases
SELECT name FROM sys.sysdatabases

UNC – Universal Naming Convention or Uniform Naming Convention

Comments Off

The UNC is a standardized method for naming servers, files, and directories in shared computer networks and for identifying the location of shared peripheral devices, such as printers, scanners, or other such resources.

The format of a UNC file name usually uses two backslashes (\\) to designate a server and a single backslash to name the path or directory on the computer drive.

The format can be illustrated as follows: \\ servername\resourcename
where servername is the host directory name of a network file server, and resourcename is the name of a networked or shared directory.

This is not the same as a DOS directory, although the format is similar.

Considering that the goal of a UNC is to reduce confusion and standardize the format, it’s ironic that Windows (and DOS) and Unix actually use different slashes to separate the components of a UNC. Unix uses forward-slashes (//), whereas DOS and Windows use backslashes (\\) to affect that separation.

With the explosive growth of the Internet (and of Web-based applications in general), UNCs are becoming more common. This makes sense because it means that a browser can refer to data that’s not stored on one particular Web serve

SQL Server Security: Database “db_datareader” Roles

Comments Off

The db_datareader role

The db_datareader role has the ability to run a SELECT statement against any table or view in the database. This role is often used in reporting databases where users would be coming in via a third-party reporting tool and building their own ad-hoc queries. If you need to restrict a user to only be able to read from certain tables, the db_datareader is not the right choice as it would have to be combined with the explicit use of DENY permissions on tables the user shouldn’t be able to access. A better practice would be to create a user-defined database role with the proper permissions.

One key point about the db_datareader role is that it always has the right to read all tables and views. That means if you create a new table in the database, a member of the db_datareader role has access immediately. This differs greatly from a user-defined role with which you must explicitly grant each permission. Therefore, unless you give a user-defined role permission to access a database object such as a table or view, that role can’t do so. Not only does it have access to user tables but also system tables. That means a member of the db_datareader role can execute a SELECT query against a system table even you decide to revoke public access to SELECT against these tables (keep in mind that revoking default permissions would result in an unsupported configuration so far as Microsoft is concerned).