EXEC SP_EXECUTESQL
@DynamicSQL
, N'@HostIDs VARCHAR(MAX) OUTPUT'
, @HostIDs OUTPUT;
PRINT @HostIDs;
SELECT @HostIDs AS HostIDs;
SET @UpdateSQL = '
EXECUTE [dbo].[usp_Win7_HostUpdater_NEW]
@HostID = ''' + @HostIDs + ''' ,
@PackageID = ''' + @PackageID + ''' ,
@MigrationFlag = ''' + @MigrationFlagID + ''' ,
@Manufacturer = ' + @Manufacturer + ' ,
@Product = ' + @Product + ' ,
@Version = ' + @Version + ' ,
@Reason = ' + @Reason + ' ,
@Contact = ' + @Contact + '
';
SELECT @UpdateSQL AS UpdateSQL;
PRINT @UpdateSQL;
EXEC( @UpdateSQL )
END
I have a stored procedure on both a SQL Server 2005 and 2008 in which the above code is the last part of
it returns a VARCHAR(MAX) of numbers separated by commas.
Now this returned value is large upwards of 600k characters. If I execute this on a SQL Server 2005 it works like 50% of the time, @HostIDs is populated always and @UpdateSQL gets generated with the correct values and is executed.
On SQL Server 2008, @HostIDs is populated but @UpdateSQL is always NULL
This is weirding me out tremendously
Can anyone maybe shed some light on my odd problem?
NULL. Did you test all of them?@UpdateSQLin the first place? (It just looks like a target for SQL injection.) Why do you not just have the command as an actual statement?