Skip to main content

All Questions

Filter by
Sorted by
Tagged with
2 votes
1 answer
50 views

Understanding how to properly create a stored procedure that only does INSERT from sourcetable to targettable with dynamic sql

Background and use-case I need to create a stored procedure where the input parameters will be: @sourceTable, @targetTable, @compositeKey. I'm using available fields for the composite key, since I ...
William's user avatar
  • 21
2 votes
1 answer
59 views

Stored procedure to swap account holders

I'm doing an exercise, and would like to know if what I'm doing is correct and follows the correct structure for rollback in case a transaction fails. I would like to know as well if my ...
KaiZ's user avatar
  • 23
2 votes
1 answer
96 views

Backing up two tables using SQL transactions

I'm using a transaction statement in SQL Server 2012 for the first time. I want to insert Table1's data in Table1_Backup before ...
tshoemake's user avatar
  • 143
2 votes
2 answers
199 views

Throwing a custom error in a stored procedure

I'm wanting to throw an error when reference keys are missing, however instead of failing through a integrity check, I want to list out the missing keys. I've created the below which works. However I'...
stats101's user avatar
  • 121
10 votes
1 answer
2k views

SQL Server stored procedure boilerplate

What would you do to improve upon this boilerplate empty stored procedure, being mindful of the delicate balance between length, complexity, performance and clarity? ...
Allbite's user avatar
  • 395