SQLTeam.com | Weblogs | Forums

Cursor/trigger

I have one main table that is Item table ,and I have one Test table same copy of Item table , I need whenever new data comes /New item added in item table then it should automatically added in Test table, right now I am manually adding.

you can use insert trigger for this. Check out the documentation on trigger. https://docs.microsoft.com/en-us/sql/t-sql/statements/create-trigger-transact-sql?view=sql-server-2017

If you enter your data with a stored procedure it would be simple to have the procedure write to your copy table at the same time, one issue with triggers is that if you have multiple entries written to the table in a single transaction, you can end up with the trigger only firing once and not everything gets copied to the secondary table, using a stored procedure is a lot more reliable.

Sounds like your trigger code only handle single row for the insert / update operation. A well written trigger will be able to handle that.