PANTHEON™ Help

 Toc
 PANTHEON Help - Welcome
[Collapse]PANTHEON
 [Collapse]Guides for PANTHEON
  [Expand]Guide for PANTHEON
  [Expand]Guide for PANTHEON Retail
  [Expand]Guide for PANTHEON Vet
  [Expand]Guide for PANTHEON Farming
 [Collapse]User Manuals for PANTHEON
  [Collapse]User Manual for PANTHEON
   [Collapse]Getting Started
     Dictionary of terms
     First steps with PANTHEON
    [Expand]Using PANTHEON at Tecta, a fictional company
    [Expand]Instructions for Ensuring Compliance of PANTHEON with SAS
    [Expand]PANTHEON Installation
    [Collapse]PANTHEON System
     [Expand]PANTHEON System data
     [Collapse]MS SQL Server
       Download and install MS SQL Server
       Upgrading MS SQL Server to 2019 or 2022
       MS Management Studio - Download and install
       Restoring database onto SQL server
       Adding users to server level (AddUser_PAX)
       Installing SQL for external access
       Installing PANTHEON clients
       Nastavitve MS SQL strežnika za večja Pantheon™ oko
       Changing SQL Sort Order
      [Expand]MS SQL Server Security
      [Collapse]Useful SQL Queries
        SQL Queries - Users
        SQL Queries - Database Backup/Restore
        SQL Queries - Databases
        SQL Queries - Jobs
       SQLExecute
      [Expand]SQL Server Jobs
     [Expand]Microsoft Windows Utilities
     [Expand]Security Policy
     [Expand]Database Administration
    [Expand]PANTHEON Basics
    [Expand]PANTHEON Help
    [Expand]Materials and Goods Movements
    [Expand]Assigning Identifiers
    [Expand]Frequently asked questions about Pantheon (F.A.Q.)
    [Expand]Archive
   [Expand]User Manual for eBusiness
   [Expand]Settings
   [Expand]Orders
   [Expand]Goods
   [Expand]Manufacturing
   [Expand]Service
   [Expand]Help
   [Expand]Personnel
   [Expand]Financials
   [Expand]Analytics
  [Expand]User Manual for PANTHEON Retail
  [Expand]User manual for PANTHEON Vet
  [Expand]User Manual for PANTHEON Farming
[Collapse]PANTHEON Web
 [Collapse]Guides for PANTHEON Web
  [Expand]Guide for PANTHEON Web Light
  [Expand]Guide for PANTHEON Web Terminal
  [Expand]Guide for PANTHEON Web Legal
  [Expand]Old products Archive
 [Collapse]User Manuals for PANTHEON Web
  [Expand]Getting started PANTHEON Web
  [Expand]User Manual for PANTHEON Web Light
  [Expand]User Manual for PANTHEON Web Terminal
  [Expand]User Manual for PANTHEON Web Legal
  [Expand]Old products Archive
[Collapse]PANTHEON Granules
 [Collapse]Guides for PANTHEON Granules
  [Expand]Personnel Granule
  [Expand]Travel Orders Granule
  [Expand]Documents and Tasks Granule
  [Expand]Dashboard Granule
  [Expand]B2B Orders Granule
  [Expand]Field Service Granule
  [Expand]Fixed Assets Inventory Granule
  [Expand]Warehouse Inventory Granule
 [Collapse]User Manuals for PANTHEON Granules
  [Expand]Getting started
  [Expand]Personnel Granule
  [Expand]Travel Orders Granule
  [Expand]Documents and Tasks Granule
  [Expand]B2B Orders Granule
  [Expand]Dashboard Granule
  [Expand]Field Service Granule
  [Expand]Fixed Assets Inventory Granule
  [Expand]Warehouse Inventory Granule
  [Expand]Archive
[Expand]User Site

Load Time: 625.0087 ms
"
  2926 | 3317 | 337270 | Updated
Label

SQL Queries - Databases

SQL Queries - Databases

SQL Queries - Databases

List of Databases and their Status

select 
    NAME, 
    DATABASEPROPERTY(name, N'IsDetached') as DETACHED,
    (case when DATABASEPROPERTY(name, N'IsShutdown') 
      is null then -1 
    else 
      DATABASEPROPERTY(name, N'IsShutdown') 
    end) as ISSHUTDOWN,
    DATABASEPROPERTY(name, N'IsSuspect') as ISSUSPECT,
    DATABASEPROPERTY(name, N'IsOffline') as ISOFFLINE,
    DATABASEPROPERTY(name, N'IsInLoad') as ISINLOAD,
    (case when DATABASEPROPERTY(name, N'IsInRecovery')
       is null then -1 
     else 
       DATABASEPROPERTY(name, N'IsInRecovery') 
     end) as ISINRECOVERY,
     (case when DATABASEPROPERTY(name, N'IsNotRecovered') 
       is null then -1
      else 
       DATABASEPROPERTY(name, N'IsNotRecovered')
      end) as ISNOTRECOVERED,
     DATABASEPROPERTY(name, N'IsEmergencyMode') as ISEMERGENCYMODE, 
     DATABASEPROPERTY(name, N'IsInStandBy'), 
     has_dbaccess(name) as ISINSTANDBY
 from master.dbo.sysdatabases

Check whether a Database Belongs to PANTHEON

select NAME 
  from dbname.dbo.SYSOBJECTS 
  where NAME = 'PARAMSYS'

ATTACH Database

The database must be located on the server in the form of .MDF and .LDF files, but must also be attached to the server.
You can attach the database with the SP_ATTACH_DB command.

sp_attach_db  @dbname='database_name',
@filename1= 'path_and_MDF_file_name',
  @filename2= 'path_and_LDF_file_name'

database_name - the name of the database that you wish to attach.
 path_and_MDF_file_name - the path and file name of the database file (.mdf).
 path_and_LDF_file_name - the path and file name of the database log file (.ldf).

Example:

sp_attach_db  @dbname='msDataLab',
  @filename1= 'c:\mssql7\data\msDataLab.MDF',
  @filename2= 'c:\mssql7\data\msDataLab.LDF'

DETACH Database

The database file and log file (.MDF and .LDF) cannot be manipulated as long as they are attached to the server. You have to detach them before you can move, delete, etc. them.

sp_detach_db @DbName='database_name'

database_name - the name of the database that you want to detach from the server.

Example:

sp_detach_db @DbName='msDataLab'

Log Size

This query returns the size of the log file (.LDF).

DBCC sqlperf(logspace)


 

Rate this topic
Was this topic usefull?
Comments
Comment will also bo visible in forum!