sql server store the result of a select in a variable?
sql, sql-server, sql-server-2008
Solution
DECLARE @Varname int
SELECT @Varname = SUM(table_name.col1) FROM etc
SELECT @Varname
Problem
I am making a function. A select statement returns only one row with one column, say an int. How do i store this int inside a declared variable so that my function can return the variable ? ``` select sum(table_name.col1) -- this line returns only one int. How to store that --in a declared variable ? from (select col1, col2 --code here )table_name ```