Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8326117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:39:47+00:00 2026-06-09T00:39:47+00:00

Declare @Count tinyint Declare @Count2 tinyint SELECT @Count2 = Count(*) FROM table where artno

  • 0
Declare @Count tinyint
Declare @Count2 tinyint

SELECT @Count2 = Count(*) FROM  table where artno = @new 

If @Count2 != 0
BEGIN
    delete from table where artno = @new
END 

I could not know what these lines of codes in the stored procedure in SQL Server are doing exactly.

I have looked into the definition of and use of count() after that as well not able to figure it out. Especially the = in the code confuses me a lot as well as * in the `count(*)´.

I am beginner so would like to apologize if its quite elementary question, I got to understand though.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T00:39:50+00:00Added an answer on June 9, 2026 at 12:39 am
    SELECT @Count2 = Count(*) FROM  table where artno = @new 
    

    gets the number fo records where artno is equal to the content in your @new varaible and stores that number in the @Count2 variable.

    If @Count2 != 0
    BEGIN
        delete from table where artno = @new
    END 
    

    deletes all records where artno is equal to the content in your @new varaible, if the @count2 is not 0

    BTW the @Count variable is not used in that code and is obsolete.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For example: declare @bitHaveRows bit select @bitHaveRows = count(*) from table where (predicate) Are
DECLARE v_count NUMBER ; begin SELECT Count(COMPLETION) INTO v_count FROM AIMS WHERE Code=997 AND
DECLARE @query as varchar(200); SET @query = 'SELECT COUNT(*) FROM table'; How can I
Which is the correct syntax? DECLARE @TotalRows INT SET @TotalRows = (SELECT COUNT(*) FROM
DECLARE @OrdersTemp TABLE ( OrderId UNIQUEIDENTIFIER ) INSERT INTO @OrdersTemp SELECT ord.Id FROM Orders
Declare @count nvarchar(max) set @count ='select COUNT(*) from '+ @tablename+'' if( @count =0 )
DECLARE @T INT EXEC('SELECT @T = count(user_id) FROM ( .. .. .. )') PRINT
DECLARE @table table(XYZ VARCHAR(8) , id int) INSERT INTO @table SELECT '4000', 1 UNION
DECLARE @Symb varchar SET @Symb = 'Lara' SELECT Names FROM Cricket where Names like
ALTER PROC SP_SampleInner AS SELECT COUNT(*) FROM TB_Whatever Other procedure ALTER RPROC SP_SampleOuter AS

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.