Blog Stats
  • Posts - 14
  • Articles - 0
  • Comments - 14
  • Trackbacks - 0

 

Monday, January 05, 2009

Debug stored procedure

It s really easy to debug a SQL sever stored procedure in Visual Studio, here are the steps:

  1. Open Server Explorer
  2. Connect to the Database which have the stored procedure that you want to debug
  3. Once you are connected to a DB, it will display DB objects in Server Explorer, Click  to expand Stored Procedures
  4. Right Click on the Stored Procedure ( that you want to debug ) 
  5. Click on 'Step Into Stored Procedure'

join in SQL update statement

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
 

 

Copyright © faizanahmad