CREATE TABLE JOBS ( JobID UNIQUEIDENTIFIER ROWGUIDCOL PRIMARY KEY NOT NULL CONSTRAINT DF_Jobs_UniqueIdentifier DEFAULT ( newid()), JobTitle VARCHAR( 100 ) NULL, JobCategory VARCHAR( 100 ) UNIQUE NULL, ) -- YÖNTEM 2 CREATE TABLE JOBS ( JobID [uniqueidentifier] ROWGUIDCOL NOT NULL, JobTitle VARCHAR( 100 ), JobCategory VARCHAR( 100 ), CONSTRAINT PK_JOBID PRIMARY KEY CLUSTERED ( JobID ASC ), CONSTRAINT UQ_JobCategory UNIQUE NONCLUSTERED ( JobCategory ASC ) ) ALTER TABLE JOBS ADD CONSTRAINT DF_Jobs_Uniqueidentifier DEFAULT ( newid()) FOR [JobID]
--DROP TABLE JOBS SELECT COUNT(*) TransactionOncesi FROM JOBS DECLARE @Error INT BEGIN TRANSACTION INSERT INTO JOBS ( JobTitle, JobCategory ) SELECT 'Bilgisayar Mühendisliği', 'Network Mühendisliği' SET @Error = @@ERROR IF( @ERROR <> 0 ) GOTO Error_Handler INSERT INTO JOBS ( JobTitle, JobCategory ) SELECT 'Bilgisayar Mühendisliği', 'Sistem Mühendisliği' SET @Error = @@ERROR IF( @Error <> 0 ) GOTO Error_Handler
--INSERT INTO JOBS (JobTitle,JobCategory) SELECT 'Bilgisayar Mühendisliği', 'Sistem Mühendisliği' SET @Error = @@ERROR IF ( @Error <> 0 ) GOTO Error_Handler COMMIT TRANSACTION Error_Handler: IF @Error <> 0 BEGIN ROLLBACK TRANSACTION END