Category Archives: Notes

All Articles

SQL Server 2005 Editions

SQL Server 2005 Editions

<!–[if !supportLists]–>ü <!–[endif]–>SQL Server Express

<!–[if !supportLists]–>ü <!–[endif]–>SQL Server Workgroup

<!–[if !supportLists]–>ü <!–[endif]–>SQL Server Developer

<!–[if !supportLists]–>ü <!–[endif]–>SQL Server Standard

<!–[if !supportLists]–>ü <!–[endif]–>SQL Server Enterprise

<!–[if !supportLists]–>ü <!–[endif]–>SQL Server Compact

System Databases in SQL Server 2005


SQL Server System Databases

  • Master
    • Purpose – Core system database to manage the SQL Server instance. In SQL Server 2005, the Master database is the logical repository for the system objects residing in the sys schema. In SQL Server 2000 and previous editions of SQL Server, the Master database physically stored all of the system objects.
    • Prominent Functionality
      • Per instance configurations
      • Databases residing on the instance
      • Files for each database
      • Logins
      • Linked\Remote servers
      • Endpoints
    • Additional Information
      • The first database in the SQL Server startup process
      • In SQL Server 2005, needs to reside in the same directory as the Resource database
  • Resource
    • Purpose – The Resource database is responsible for physically storing all of the SQL Server 2005 system objects. This database has been created to improve the upgrade and rollback of SQL Server system objects with the ability to overwrite only this database.
    • Prominent Functionality
      • System object definition
    • Additional Information
      • Introduced in SQL Server 2005 to help manage the upgrade and rollback of system objects
      • Prior to SQL Server 2005 the system related data was stored in the master database
      • Read-only database that is not accessible via the SQL Server 2005 tool set
      • The database ID for the Resource database is 32767
      • The Resource database does not have an entry in master.sys.databases
  • TempDB
    • Purpose – Temporary database to store temporary tables (#temptable or ##temptale), table variables, cursors, work tables, row versioning, create or rebuild indexes sorted in TempDB, etc. Each time the SQL Server instance is restarted all objects in this database are destroyed, so permanent objects cannot be created in this database.
    • Prominent Functionality
      • Manage temporary objects listed in the purpose above
    • Additional Information
      • Each time a SQL Server instance is rebooted, the TempDB database is reset to its original state
  • Model
    • Purpose – Template database for all user defined databases
    • Prominent Functionality
      • Objects
      • Columns
      • Users
    • Additional Information
      • User defined tables, stored procedures, user defined data types, etc can be created in the Model database and will exist in all future user defined databases
      • The database configurations such as the recovery model for the Model database are applied to future user defined databases
  • MSDB
    • Purpose – Primary database to manage the SQL Server Agent configurations
    • Prominent Functionality
      • SQL Server Agent Jobs, Operators and Alerts
      • DTS Package storage in SQL Server 7.0 and 2000
      • SSIS Package storage in SQL Server 2005
    • Additional Information
      • Provides some of the configurations for the SQL Server Agent service
      • For the SQL Server 2005 Express edition installations, even though the SQL Server Agent service does not exist, the instance still has the MSDB database
  • Distribution
    • Purpose – Primary data to support SQL Server replication
    • Prominent Functionality
      • Database responsible for the replication meta data
      • Supports the data for transaction replication between the publisher and subscriber(s)
  • ReportServer
    • Purpose – Primary database for Reporting Services to store the meta data and object definitions
    • Prominent Functionality
      • Reports security
      • Job schedules and running jobs
      • Report notifications
      • Report execution history
  • ReportServerTempDB
    • Purpose – Temporary storage for Reporting Services
    • Prominent Functionality
      • Session information
      • Cache
  • GIS DataTypes in SQL Server 2008

    Microsoft’s SQL Server 2008 offers new support for spatial data types that some analysts say should deliver a real boost to geospatial applications and data sharing.

    Expected to ship in the third quarter, the new version of SQL Server will allow storage of spatial data — in the form of points, lines and polygons — in SQL tables. The software will also offer a set of functions to allow the manipulation of this data and new spatial indexes to support the execution of these functions.

    What is GIS?

    geographic information system (GIS) integrates hardware, software, and data for capturing, managing, analyzing, and displaying all forms of geographically referenced information.

    Why GIS?

    GIS allows us to view, understand, question, interpret, and visualize data in many ways that reveal relationships, patterns, and trends in the form of maps, globes, reports, and charts.

    A GIS helps you answer questions and solve problems by looking at your data in a way that is quickly understood and easily shared.

    GIS technology can be integrated into any enterprise information system framework.

    A GIS can be viewed in three ways:

    1. The Database View

    2. The Map View

    3. The model View

    XP_cmdshell extended stored procedure (Execute Winows commands)

    xp_cmdshell

    Executes a given command string or batch file as an operating-system command shell and returns any output as rows of text.

    Permission/Rights: Only SysAdmin fixed role can execute it.

    Syntax

    xp_cmdshell {command_string} [, no_output]

    Arguments

    command_string

    Is the command string to execute at the operating-system command shell or from DOS prompt. command_string is varchar(255) or nvarchar(4000), with no default.

    command_string cannot contain more than one set of double quotation marks.

    A single pair of quotation marks is necessary if any spaces are present in the file paths or program names referenced by command_string.

    If you have trouble with embedded spaces, consider using FAT 8.3 file names as a workaround.

    no_output

    Is an optional parameter executing the given command_string, and does not return any output to the client.

    Examples
    xp_cmdshell 'dir *.jpg'

    Executing this xp_cmdshell statement returns the following result set:

    xp_cmdshell 'dir *.exe', NO_OUTPUT

    Here is the result:

    The command(s) completed successfully.

    <!–[if gte vml 1]&gt; &lt;![endif]–><!–[if !vml]–><!–[endif]–>

    Examples
    Copy File
    EXEC xp_cmdshell 'copy c:\sqldumps\jshah143.bak \\server2\backups\jshah143.bak',  NO_OUTPUT
     
    Use return status

    In this example, the xp_cmdshell extended stored procedure also suggests return status. The return code value is stored in the variable @result.

    DECLARE @result int
    EXEC @result = xp_cmdshell 'dir *.exe'
    IF (@result = 0)
       PRINT 'Success'
    ELSE
       PRINT 'Failure'

     

    Pass the parameter to batch file

    DECLARE @sourcepath VARCHAR(100)
    DECLARE @destinationpath VARCHAR(1000)
    SET @sourcepath = ' c:\sqldumps\jshah143.bak '
    SET @destinationpath = '\\server2\backups\jshah143.bak'
     
    SET @CMDSQL = 'c:copyfile.bat' + @sourcepath + @destinationpath
    EXEC master..XP_CMDShell @CMDSQL

    How to read transaction log data in SQL Server 2000/2005?

     

    We can’t read the transaction logs directly from SQL Server. Some products do allow you to read the logs, such as:

    * Apex SQL Log (Works with MSSQL2000 and MSSQL2005)
    * Log Explorer
    * SQL Log Rescue (Only work with the SQL Server 2000)

    The below undocumented DBCC command is working in both SQL Server 2000 & SQL Server 2005

    DBCC LOG(<database name>[,{0|1|2|3|4}])
    0 – Basic Log Information (default)
    1 – Lengthy Info
    2 – Very Length Info
    3 – Detailed
    4 – Full Example
    Syntax:
    DBCC log (MY_DB, 4)

    Another undocumented command is DBCC LOGINFO