A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
Hi @hari prasad ,
Welcome to the microsoft TSQL Q&A forum!
If #sales1 has been created, then:
IF (SELECT Count (*) FROM #sales)>0
INSERT INTO
#sales1
SELECT SUM(Salesamt)
FROM #sales
ELSE
PRINT 0
If #sales1 has not been created yet, then:
IF (SELECT Count (*) FROM #sales)>0
SELECT SUM(Salesamt) ss
INTO #sales1
FROM #sales
ELSE
PRINT 0
If you have any question, please feel free to let me know.
If the response is helpful, please click "Accept Answer" and upvote it.
Regards
Echo
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.