Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2003
    Posts
    10

    Unanswered: dynamic query problem.

    I am using dynamic query in a Sybase stored procedure. I am getting a strange error where I see that the query I am initializing using
    Select @query1 = " select
    ******************
    ******************
    Does not get initialize fully, I mean some characters towards the end are left (this I verified by printing the query the proc is executing), and it give error when I execute the proc as the query in not complete. Can someone help how to get over it? I am sure size of query1 as declared is not a problem.

  2. #2
    Join Date
    Jul 2004
    Posts
    61
    You can not retrieve data by running a dinamic query.
    You can insert data in to temp table and then select data from temp table
    Ex:

    begin
    declare @str varchar(1000);
    set @str='select str.str, str.id into #temp from str ';
    execute immediate @STR;
    set @STR='insert into #temp(str,id) select str.str, str.id from str union select ''ss'', 99';
    execute immediate @STR;
    select* from #temp
    end

    Good luck
    Thi Nguyen

Posting Permissions

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