Posts

Showing posts from December, 2021

Back up sql server task scheduler window

Image
Running scheduled tasks in SQL Server Express has to be done differently due to the limitations of the Edition. As well as having a maximum database size of 10GB and 1GB consumable RAM, Express does include the SQL Server Agent. So, If you need a task to run on a time based schedule, you’ll have to look outside of SQL Server. Windows Task Scheduler is where I’d steer to, running a PowerShell or DOS script which utilises sqlcmd. The DOS approach is further explained within the following steps; #  Locate/install sqlcmd . #   Create .bat sqlcmd script . #   Create Scheduled Task . The .bat script for this post will execute  Ola Hallengren’s Index Maintenance , which I’ll set to run weekly on the Express instance of SQL. Ola’s index maintenance stored proc is assumed to be on the SQL Server for this task. Locate/Install Sqlcmd The sqlcmd utility is installed with SSMS, or you can  download separate Windows & Linux clients . If you already have SSMS installed, you can find the directory

Trigger Audit Create Update Delete in SQL server

  /****** Object:  StoredProcedure [dbo].[GenerateTriggers]    Script Date: 12/23/2021 2:29:50 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO     CREATE PROC [dbo].[GenerateTriggers]     @Schemaname Sysname = 'dbo'    ,@Tablename  Sysname    ,@GenerateScriptOnly    bit = 1   ,@ForceDropAuditTable   bit = 0   ,@IgnoreExistingColumnMismatch   bit = 0   ,@DontAuditforUsers NVARCHAR(4000) =  '' ,@DontAuditforColumns NVARCHAR(4000) =  '' AS        SET NOCOUNT ON        /*    Parameters    @Schemaname            - SchemaName to which the table belongs to. Default value 'dbo'.    @Tablename            - TableName for which the procs needs to be generated.    @GenerateScriptOnly - When passed 1 , this will generate the scripts alone..                          When passed 0 , this will create the audit tables and triggers in the current database.                          Default value is 1    @ForceDropAuditTable - When passed 1 , will drop the audit

Run SSIS command line

  "C:\Program Files\Microsoft SQL Server\150\DTS\Binn\DTExec.exe" /f "E:\PMD\Document\Transcosmos.Ssis.Project\Transcosmos.Ssis.HR\SyncDataPkg.dtsx"

/aspnet-core-identity-authentication

  Nguồn: https://www.yogihosting.com/aspnet-core-identity-authentication/

How to convert Time to Decimal in SQL with an integer

  How to convert Time to Decimal in SQL with an integer I am having a couple of issues converting time to decimal... Essentially I have used a DATEDIFF to identify the hours and minutes between two dates and times. This produces a result of 5.45, however I would like to get the result as 5.75. select RTRIM(DATEDIFF( second , startdate, enddate) / 3600 ) + '.' + RIGHT ( '0' + RTRIM((DATEDIFF( second , startdate, enddate) % 3600 ) / 60 ), 2 ) from time I have tried a few things but I believe the issue is that this is not an integer and that's why i cant convert the minutes. Asked By: Withdalot || Source Answer #1: Get the time difference in minutes, and divide by 60, this will place hours before the decimal separator and minutes after: datediff( minute , startdate, enddate) / 60.0 Answered By: Guffa Answer #2: Select DATEDIFF( second , startdate, enddate) / 3600.0 Answered By: bummi Answer #3: As mentioned in  this answer , "Take the DateDiff in second