While it is strongly recommended that you have a primary key on your employee table as well as a foreign key for your position table, you do not need it for a trigger. You should always have a primary key on a table, otherwise you have no ability to uniquely identify a row. If you have tables that relate to each other, you should also have a foreign key in order to ensure that you can not orphan data in those related tables.
If positiontable is not related at all to employee, then you can simply do this by the following:
Update positiontable Set icurrentstrength = icurrentstrength + 1That would, of course, increment every single row in positiontable when a row was inserted into employee.
For More Information
- Dozens more answers to tough SQL Server questions from Michael Hotek are available here.
- The Best Microsoft SQL Server Web Links: tips, tutorials, scripts, and more.
- Have a SQL Server tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize. Submit your tip today!
- Ask your technical SQL Server questions -- or help out your peers by answering them -- in our live discussion forums.
- Ask the Experts yourself: Our SQL, database design, SQL Server, DB2, object-oriented and data warehousing gurus are waiting to answer your toughest questions.
Dig Deeper on Microsoft SQL Server Installation
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.