It s really easy to debug a SQL sever stored procedure in Visual Studio, here are the steps:
- Open Server Explorer
- Connect to the Database which have the stored procedure that you want to debug
- Once you are connected to a DB, it will display DB objects in Server Explorer, Click to expand Stored Procedures
- Right Click on the Stored Procedure ( that you want to debug )
- Click on 'Step Into Stored Procedure'
I had to update value from a staging table( this might be a temp table ) into another database table. Here is how I did it using a inner join in the Update statement.
UPDATE Table1
SET Table1.Field1 = StagingTable.Field1
FROM Table1 INNER JOIN StagingTable ON Table1.Field2 = StagingTable.Field2
You can also add a where clause to this SQL:
WHERE StagingTable.Field3 IS NOT NULL
---------------------------------------------------------------------
Same way we can use JOINs in insert and delete statements