Home Forums SQL Server 2008 T-SQL (SS2K8) Select All Records from Temporary Table and Assign to VARCHAR? RE: Select All Records from Temporary Table and Assign to VARCHAR?

  • You might want to try something like this

    Declare @msg varchar(8000),

    @TargetData varchar(max)

    Set @TargetData = "Target Project Name"

    Set @msg= 'Are you sure you wish to copy the following records to: ' + @TargetData + '?'

    SELECT @msg = @msg + CHAR(10) + SourceKey + ' [' + SourceID +'] '+ SourceComment

    FROM (

    SELECT DISTINCT SourceKey, SourceID, SourceComment

    FROM #TempSourceOutput t2) t

    ORDER BY SourceKey

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2