View Single Post
  #2 (permalink)  
Old April 7th, 2008, 03:41 AM
Preethi Preethi is offline
Authorized User
 
Join Date: Jun 2003
Location: Colombo 04, WP, Sri Lanka.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Preethi Send a message via Yahoo to Preethi
Default

To Get the value back to a variable you should use sp_ExecuteSQL
Here is an example of what I tried against AdventureWorks

DECLARE @SQL nvarchar(2000), @Rows int
SET @SQL =N'SELECT @RowCount =COUNT(*) FROM '+ +'Sales.SalesOrderHeader'
EXEC sp_ExecuteSQL @SQL, N'@RowCount int OUTPUT',@RowCount=@Rows OUTPUT
SELECT @Rows

I purposefully used @RowCount and @Rows to differentiate them. Hope this helps


G.R.Preethiviraj Kulasingham
Reply With Quote