milosev.com
  • Home
    • List all categories
    • Sitemap
  • Downloads
    • WebSphere
    • Hitachi902
    • Hospital
    • Kryptonite
    • OCR
    • APK
  • About me
    • Gallery
      • Italy2022
      • Côte d'Azur 2024
    • Curriculum vitae
      • Resume
      • Lebenslauf
    • Social networks
      • Facebook
      • Twitter
      • LinkedIn
      • Xing
      • GitHub
      • Google Maps
      • Sports tracker
    • Adventures planning
  1. You are here:  
  2. Home

Log in trigger

Details
Written by: Stanko Milosev
Category: MS SQL
Published: 26 March 2020
Last Updated: 26 March 2020
Hits: 4327
One my example how to log messages in trigger.

Create table:

create table log (tableName varchar(max), msg varchar(max))
Log in trigger:
declare @xml XML

set @xml = (select * from deleted for xml auto, elements )
insert into log(tableName, msg) values('deleted', cast(@xml as varchar(max)))

Drop if exists

Details
Written by: Stanko Milosev
Category: MS SQL
Published: 13 March 2020
Last Updated: 13 March 2020
Hits: 3175
Here are few "DROP IF EXISTS" SQL statements, for my future reference.

Trigger from sys.objects:

IF EXISTS (SELECT * FROM sys.objects WHERE [name] = N'myTrigger' AND [type] = 'TR')
BEGIN
      DROP TRIGGER [dbo].[myTrigger];
END;
GO
Stored procedure with OBJECT_ID:
IF OBJECT_ID('dbo.mySP') IS NOT NULL
  DROP PROCEDURE dbo.mySP
GO
Temp table:
IF OBJECT_ID('tempdb..#myTempTable') IS NOT NULL DROP TABLE #myTempTable
GO

The login already has an account under a different user name.

Details
Written by: Stanko Milosev
Category: MS SQL
Published: 11 February 2013
Last Updated: 04 July 2013
Hits: 10091

If you receive error like:

The login already has an account under a different user name. (Microsoft SQL Server, Error: 15063)

Then just take databse offline and back online. Frome here.

Access SQL Server from other machines

Details
Written by: Stanko Milosev
Category: MS SQL
Published: 12 November 2012
Last Updated: 26 December 2012
Hits: 5998

SQL Server Browser has to be enabled so that other machines can access it.

  1. How to change sa password.
  2. Query to Find Column From All Tables of Database
  3. Select all from all tables in DB
  4. Invoke or BeginInvoke cannot be called on a control until the window handle has been created..

Subcategories

C#

Azure

ASP.NET

JavaScript

Software Development Philosophy

MS SQL

IBM WebSphere MQ

MySQL

Joomla

Delphi

PHP

Windows

Life

Lazarus

Downloads

Android

CSS

Chrome

HTML

Linux

Eclipse

Page 79 of 168

  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83