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

Microsoft SQL ServerMicrosoft Access

Avatar of undefined
Last Comment
sventhan

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
sventhan

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Lowfatspread


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

@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.

Your help has saved me hundreds of hours of internet surfing.
fblack61