Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Trigger is locking up record
Message
De
30/04/2004 10:38:15
 
 
À
30/04/2004 09:09:44
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
00899034
Message ID:
00899767
Vues:
20
IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = N'ForTesting')
DROP DATABASE [ForTesting]
GO

CREATE DATABASE [ForTesting] ON (NAME = N'ForTesting_Data', FILENAME = N'E:\MSSQL7\data\ForTesting_Data.MDF' , SIZE = 1, FILEGROWTH = 10%) LOG ON (NAME = N'ForTesting_Log', FILENAME = N'E:\MSSQL7\data\ForTesting_Log.LDF' , SIZE = 1, FILEGROWTH = 10%)
COLLATE SQL_Latin1_General_CP1_CI_AS
GO

exec sp_dboption N'ForTesting', N'autoclose', N'false'
GO

exec sp_dboption N'ForTesting', N'bulkcopy', N'false'
GO

exec sp_dboption N'ForTesting', N'trunc. log', N'false'
GO

exec sp_dboption N'ForTesting', N'torn page detection', N'true'
GO

exec sp_dboption N'ForTesting', N'read only', N'false'
GO

exec sp_dboption N'ForTesting', N'dbo use', N'false'
GO

exec sp_dboption N'ForTesting', N'single', N'false'
GO

exec sp_dboption N'ForTesting', N'autoshrink', N'false'
GO

exec sp_dboption N'ForTesting', N'ANSI null default', N'false'
GO

exec sp_dboption N'ForTesting', N'recursive triggers', N'false'
GO

exec sp_dboption N'ForTesting', N'ANSI nulls', N'false'
GO

exec sp_dboption N'ForTesting', N'concat null yields null', N'false'
GO

exec sp_dboption N'ForTesting', N'cursor close on commit', N'false'
GO

exec sp_dboption N'ForTesting', N'default to local cursor', N'false'
GO

exec sp_dboption N'ForTesting', N'quoted identifier', N'false'
GO

exec sp_dboption N'ForTesting', N'ANSI warnings', N'false'
GO

exec sp_dboption N'ForTesting', N'auto create statistics', N'true'
GO

exec sp_dboption N'ForTesting', N'auto update statistics', N'true'
GO

use [ForTesting]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[testing]') and OBJECTPROPERTY(id, N'IsTrigger') = 1)
drop trigger [dbo].[testing]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Table1]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Table1]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Table2]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Table2]
GO

CREATE TABLE [dbo].[Table1] (
[TT1ID] [int] IDENTITY (1, 1) NOT NULL ,
[TT1D1] [char] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[TT1D2] [char] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[Table2] (
[TT2ID] [int] IDENTITY (1, 1) NOT NULL ,
[TT2D1] [char] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[TT2D2] [char] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO

SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

CREATE TRIGGER [testing] ON [dbo].[Table1]
FOR INSERT, UPDATE
AS

Declare @Data1 char(10)

set @Data1 = (Select TT1D1 from inserted)

insert into Table2 (TT2D1) values (@Data1)
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
Thank You

Rollin Burr

Politicians and diapers have one thing in common. They should both be changed regularly, and for the same reason.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform