Results 1 to 4 of 4

Thread: Exec @string

  1. #1
    Join Date
    Oct 2005
    Posts
    58

    Unanswered: Exec @string

    I am trying to do an insert statement utilizing a variable string.

    something like:

    Set @cString = 'SELECT top 10 *
    FROM OPENDATASOURCE(
    ' + char(39) + 'SQLOLEDB' + char(39) + ',' + char(39) +
    'Data Source=' + @lServer + ';User ID=' + @user + ';Password=' + @pword + char(39) + '
    ).myServer..

    Insert into #Temp_table (field1, field2)
    select exec @cString

    --What is the syntax for this?

  2. #2
    Join Date
    May 2002
    Posts
    299
    as answered in previous post. you can like so:

    insert tb
    exec(@sql)
    --
    -oj
    http://www.rac4sql.net

  3. #3
    Join Date
    Oct 2005
    Posts
    58
    When I do something like:

    Insert into #tACCOUNT (ACCOUNTID, ACCOUNT, TYPE)
    exec (@cString)


    I get:

    MSDTC on server 'myServer' is unavailable.

  4. #4
    Join Date
    May 2002
    Posts
    299
    dtc is needed to ensure data integrity between 2 sites. when you do any dml, the transaction is implicitly promoted to a distributed transaction.
    --
    -oj
    http://www.rac4sql.net

Posting Permissions

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