Link to home
Start Free TrialLog in
Avatar of shilpi2
shilpi2

asked on

count

hi experts,

I am trying to count the rows in a table and assign the count to a variable.
I am getting an error in this case.
says that:

Server: Msg 170, Level 15, State 1, Procedure IDX_Daily_Security_Dollars_Earned_Calc_Strategy, Line 98
Line 98: Incorrect syntax near '@a'.

declare @a int
SELECT COUNT(StartDate) into @a FROM #TEMP_All_Dates 
if @a=1
begin
insert into #TEMP_All_Dates(StartDate) values (null)
end

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of sventhan
sventhan
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Lowfatspread

insert into #TEMP_All_Dates(StartDate)
     Select null  from #temp_all_dates having count(startdate) = 1
@shilpi2

Could you please split the points? The expert LowfatSpread's has given a neat answer and that will be better than my solution.


Thanks for the understanding.