SQL Query to get Count within a Stored Proc
        Posted  
        
            by sia
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by sia
        
        
        
        Published on 2010-03-16T14:00:26Z
        Indexed on 
            2010/03/16
            14:06 UTC
        
        
        Read the original article
        Hit count: 320
        
So i need to figure out how i can get a record count value and use that count as a new value to insert into a table.
Ex: In My Stored Procedure
@Count int
What im looking for
@Count to equal "select top (1) _fieldName from _someTable order by _fieldName Desc"
Finally
insert into _newTable (_fieldName) values (@Count)
End
I dont have to use a variable, just trying to demonstrate what im really trying to do. My SQL knowledge is pretty limited so no laughing, or smirking! ;)
© Stack Overflow or respective owner