how to get the row count value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cmrhema
    Contributor
    • Jan 2007
    • 375

    how to get the row count value

    Hi,

    I have to insert a row in a table and update in another table if it already exists.
    Infact i have to find out if there are any rows inside the second table , if exists then update, else insert

    declare @count nvarchar(10)
    declare @maxdattime datetime
    declare @UnitNo nvarchar(50)
    declare @t1 nvarchar(50)
    declare @str nvarchar(1000)
    set @t1='gpsdata'
    set @UnitNo='352022 000637171'

    select @str='declare @count nvarchar(10);se lect @count=count(*) from '+@t1+' where unit_no=''35202 2000637171'';se lect @count'
    print @str
    exec ( @str)

    I have given the table name as a variable, because i have to get that too.
    Its just a part of the original sp

    Now i want to have the count value

    How do i get it
    Kindly help
    regards
    cmrhema
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    have you tried using SELECT INTO Statement ?

    Comment

    Working...