How to retrieve a declared variable in sql server -


using code below (which found here), variable 20 million rows being created. find stored variable. able locate tables i've created particular variable isn't visible.

my end goal export variable , values in csv format. how make happen.

declare @p_numberofrows bigint  --we need 20 million rows  select @p_numberofrows=20000000;  base ( select 1 n union select n+1 base n < ceiling(sqrt(@p_numberofrows)) ), expand ( select 1 c base b1, base b2 ), nums ( select row_number() over(order c) n expand ) select n nums n<=@p_numberofrows  --remove maximum recursion level constraint  option (maxrecursion 0); 

well depending on how handling result set in application going create csv, there seem several ways go.

first add variable count every row returned in select

select n, @p_numberofrows numberofrows nums n<=@p_numberofrows 

or return 2 results sets, 1 data , 1 number of rows variable

select n nums n<=@p_numberofrows select @p_numberofrows numberofrows  

or store number of rows variable in table run_instance_id , date , pull that. if need see number of rows @ future date sent on particular run.


Comments

Popular posts from this blog

gridview - Yii2 DataPorivider $totalSum for a column -

java - Suppress Jboss version details from HTTP error response -

Sass watch command compiles .scss files before full sftp upload -