Reputation: 25
(How) Can I Sql Server create a parameter that is automatically populated from data - in other words equivalent to SAS' "Proc Sql; into:" - functionality
In SAS I can store the number of rows in a table, mytable, into a macro variable, n_rows. I am looking for something like this in sql server.
proc sql noprint;
select count(*) into :n_rows
from mytable
quit;
%put &n_rows.;
Upvotes: 1
Views: 44
Reputation: 2191
Maybe I am missing something, but is this what you're looking for?
declare @numberOfRows int = (select count(*) from myTable)
select @numberOfRows
Upvotes: 1