Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2010
    Posts
    2

    Unanswered: what is the alternative of exec in function

    Hi to all,

    i have a question- what is the alternative of 'exec' in a function ?

    i have a function in which i want to do multiple row insert from a select query into a table variable.

    CREATE function f_getDistinctDealsV2()

    returns

    @tblDeals table

    (

    DealID int,
    prdDetailID int ,

    CaseNumber int,

    DealName varchar(250) ,

    Description varchar(500),
    Retailer bit ,

    Restaurant bit ,

    Pour bit ,

    Stores varchar(8000),
    CreatedDate datetime,

    ExpiryDate datetime,

    Amount money,

    Active bit

    )
    AS

    BEGIN



    insert into @tblDeals exec('SELECT * FROM tbl_DealsV2')
    --the above select query will later be replace by some complex select query.



    return

    END

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Code:
    insert into @tblDeals
       SELECT * FROM tbl_DealsV2
    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  3. #3
    Join Date
    Sep 2010
    Posts
    2

    what is the alternative of exec in function

    thanks. it works.

Tags for this Thread

Posting Permissions

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