From your friend, Books online (BOL)DECLARE @IntVariable int;DECLARE @SQLString nvarchar(500);DECLARE @ParmDefinition nvarchar(500);/* Build the SQL string one time.*/SET @SQLString = N'SELECT BusinessEntityID, NationalIDNumber, JobTitle, LoginID FROM AdventureWorks2008R2.HumanResources.Employee WHERE BusinessEntityID = @BusinessEntityID';SET @ParmDefinition = N'@BusinessEntityID tinyint';/* Execute the string with the first parameter value. */SET @IntVariable = 197;EXECUTE sp_executesql @SQLString, @ParmDefinition, @BusinessEntityID = @IntVariable;/* Execute the same string with the second parameter value. */SET @IntVariable = 109;EXECUTE sp_executesql @SQLString, @ParmDefinition, @BusinessEntityID = @IntVariable;
Brett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxWant to help yourself?http://msdn.microsoft.com/en-us/library/ms130214.aspxhttp://weblogs.sqlteam.com/brettk/http://brettkaiser.blogspot.com/