Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

getting value for a variable from a looping sql query

$
0
0

I have a table called projects. This table has about 5 rows in it.  In that table there is a fields called projectschema. I have a query that I want to run using the projectschema as a schema variable (@client).

At the end of the query I have a print statement.  I need the final output to be 5 lines (one for each row in the projects table).

Example:

Declare @MaxAmount

Set @MaxAmount = (Select max (amount)  from @sclient.tableX )

Print the largest amount for @client is @MaxAmount.

 


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>