Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2003
    Posts
    16

    Angry Unanswered: Return a value from EXEC

    Hi everybody

    How to return a value like that
    I dont want to use Stored proc.
    Thanks

    DECLARE @cpt as integer
    DECLARE @pTable as varchar(40)

    Select @pTable = 'Salaires'
    SELECT @cpt = EXEC('Select Count(*) FROM ' + @pTable)

    Print @cpt

  2. #2
    Join Date
    Oct 2001
    Location
    England
    Posts
    426
    declare @i int
    declare @sql nvarchar(1000)
    select @sql = 'Select @i = Count(*) FROM ' + @pTable
    exec sp_executesql @sql, N'@i int out', @i out
    select @i

    see
    http://www.nigelrivett.net/sp_executeSQL.html

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •