Categories
SQL SQL Server

Getting Database Stats

You could use sp_helpdb [ [ @dbname= ] ‘name’ ]

Categories
SQL Server

How To Obtain a List of DTS Packages

exec msdb..sp_enum_dtspackages

Categories
SQL Server

DTS Package – Check for file before importing into database

‘ Rename File from Connection Option Explicit Function Main() Dim oFSO Dim sFileName sFilename = DTSGlobalVariables.Parent.Connections(“Text File (Source)”).DataSource Set oFSO = CreateObject(“Scripting.FileSystemObject”) ‘ Check for file and return appropriate result If oFSO.FileExists(sFilename) Then ‘Main = DTSTaskExecResult_Success Main = DTSStepScriptResult_ExecuteTask Else ‘Main = DTSTaskExecResult_Failure Main = DTSStepScriptResult_DontExecuteTask End If Set oFSO = Nothing End Function

Categories
SQL Server

DTS Package – Move Imported Data File to an Archive Directory

‘ Rename File from Connection Option Explicit Function Main() Dim oPkg Dim oConn Dim oFSO Dim oFile Dim sFilename Dim sFileDestination Dim sMonth Dim sDay Dim sYear Dim sHour Dim sMinute Dim sSecond ‘ Get reference to the current Package object Set oPkg = DTSGlobalVariables.Parent ‘ Get reference to the named connection Set oConn = […]

Categories
SQL Server

SQL SERVER – Retrieve Information of SQL Server Agent Jobs

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

Categories
SQL Server

SQL SERVER – 2005 – List all the database

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

Categories
SQL Server

SQL Server Security: Database “db_datareader” Roles

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 […]

Categories
SQL Server

Convert Julian Dates in SQL SERVER

SQL SERVER JULIAN TO DATE (WHEN DOWNLOADING JULIAN DATE) date field has to be nvarchar or varchar or character. declare @DateP char(10) select @datep=107277 — ALSO OK FOR 99 YEARS select dateadd(dd,@datep-(@datep/1000)*1000-1, convert(datetime,’01/01/’+ right(convert(varchar,@datep/1000),2))) as Date_ENT

Categories
SQL SQL Server

SQL: YYYYMMDD

SELECT CONVERT(VARCHAR(8), GETDATE()-365, 112) This is a way to query and get the date in the following format: YYYYMMDD I came across some dates saved in the database in this format as a varchar and had to use this to initially get the date and then convert it from and integer to varchar.

Categories
SQL SQL Server

Standard Date Formats

View Standard Date Formats