James S
James S

Reputation: 25

Create parameter

(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

Answers (1)

DaggeJ
DaggeJ

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

Related Questions