TSQL: Consider SCOPE_IDENTITY() instead of @@IDENTITY

Problem I have two tables with ID column that has IDENTITY property. A trigger on Table1, if I insert data into Table1, the trigger will be fired up to insert data into Table2 Use Demo; GO CREATE TABLE Table1(ID int IDENTITY, value varchar(1)) CREATE TABLE Table2(ID int IDENTITY, value varchar(1)) GO CREATE TRIGGER trg_InsertIntoTable2 ON … Continue reading TSQL: Consider SCOPE_IDENTITY() instead of @@IDENTITY

Advertisements

TSQL: Avoid SELECT * in your batch code

Problem I created a table and a store procedure a few days ago. In my store procedure, I used a temporary table with structure as same as the base table created. Table USE Demo GO IF OBJECT_ID(N'Employee') IS NOT NULL DROP TABLE Employee GO CREATE TABLE Employee ( EmployeeID int, FirstName nvarchar(50), LastName nvarchar(50), Title nvarchar(50), Email … Continue reading TSQL: Avoid SELECT * in your batch code