By GokiSoft.com| 19:50 09/02/2022|
SQL Server/MySQL

[Video] Overview kiến thức SQL Server - C2108L



-- Tao CSDL
create database Test
go

-- Active CSDL
use Test
go

create table category (
	id int primary key identity(1,1),
	name nvarchar(50)
)
go

insert into category (name)
values
('A'),
('B'),
('C')
go

select * from category

delete from category where id = 3

delete from category where id >= 4

alter trigger trigger_delete_category on category
after delete
as
begin
	declare @max int
	select @max=max([id]) from category
	if @max IS NULL   --check when max is returned as null
	  SET @max = 0
	DBCC CHECKIDENT ('[category]', RESEED, @max)
end




Tags:



Phản hồi từ học viên

5

(Dựa trên đánh giá ngày hôm nay)

Đăng nhập để làm bài kiểm tra

Chưa có kết quả nào trước đó