troubleshooting Question

SQL Server 2008 R2 - How to update a record field/colum using @SQL

Avatar of Amour22015
Amour22015 asked on
Microsoft SQL ServerMicrosoft SQL Server 2008SSISSQL
2 Comments1 Solution667 ViewsLast Modified:
Hi experts,

I am executing a stored procedure using SSIS and am passing one parameter to that SP

The passing of the parameter works fine.

I just need to get this part to work:
    PRINT 'STARTING UPDATE OF CLAIM RECORDS IN DATABASE_TABLES: ' + @TBLNM
      SET @rc = 1
      WHILE @rc > 0
      BEGIN
      SELECT @sql =  'IF OBJECT_ID (''dbo.' + @TBLNM + ''') IS NULL
      UPDATE DATABASE_TABLES set TBL_STAT = ' +'DELETED' + 'WHERE TBL_NM =' + @TBL_NM +' and TBL_STAT =' + 'PURGE_ELIG'
          exec sp_executesql @sql;
                 
         
                  SET @rc = @@ROWCOUNT
      END;
      PRINT 'ENDING UPDATE OF CLAIM RECORDS IN DATABASE_TABLES: ' + @TBLNM

The reason why I am using a dynamic query is because of the parameter "@TBLNM"

I want to make sure the table that is indicated by the @TBLNM is NOT there (Has already been deleted) then to mark it in the record of DATABASE_TABLES as 'DELETED' in the correct field "TBL_STAT "

I know I am close to solving and just wanted an expert touch to finish it off...

Please help and thanks
ASKER CERTIFIED SOLUTION
John_Vidmar

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros