Professional Web Applications Themes

Dont want to see the exec sp_executesql result - Microsoft SQL / MS SQL Server

Hi! I have a problem, i dont want the exec sp_executesql to promt anything to the screen. Just run in the backgroung and dont show the result. sql code: .... SELECT sSQL = sSQL + ' LEFT OUTER JOIN it_reg_kringut AS kringut on kringut.id = ut_kringut.kringut_id ' .... IF(markt <> sStandardValue) BEGIN SELECT sSQL = sSQL + ' AND (ut.markt = ''' + markt + ''' ) ' END Declare subSql nvarchar(1024) Declare iCount int set iCount = 0 set subSql = 'SELECT count(id) FROM it_reg_utrustning_kringut AS kringut WHERE (1=1) ' + kringut exec sp_executesql subSql, N'TotalRecords int output', iCount ...

  1. #1

    Default Dont want to see the exec sp_executesql result

    Hi!

    I have a problem, i dont want the exec sp_executesql to
    promt anything to the screen. Just run in the backgroung
    and dont show the result.

    sql code:

    ....

    SELECT sSQL = sSQL + ' LEFT OUTER JOIN it_reg_kringut AS
    kringut on kringut.id = ut_kringut.kringut_id '

    ....

    IF(markt <> sStandardValue)
    BEGIN
    SELECT sSQL = sSQL + ' AND (ut.markt = ''' + markt
    + ''' ) '
    END


    Declare subSql nvarchar(1024)
    Declare iCount int

    set iCount = 0

    set subSql = 'SELECT count(id) FROM
    it_reg_utrustning_kringut AS kringut WHERE (1=1) ' +
    kringut

    exec sp_executesql subSql, N'TotalRecords int output',
    iCount output

    IF(iCount = 0)
    BEGIN
    SELECT sSQL = sSQL + ' AND (1=2)'
    END

    EXEC(sSQL)
    GO




    First i get the exec sp_executesql info and then the EXEC
    (sSQL) info. I just want the EXEC(sSQL) to view.


    Hope you understod something =)
    Anders

    anders Guest

  2. #2

    Default Re: Dont want to see the exec sp_executesql result

    The sample I provided is precisely what you are asking for (unless I did not
    understand your requirement :-))
    By replacing SELECT nlevel with your EXEC (sql), you will get only that
    output.
    --
    HTH,
    SriSamp
    Please reply to the whole group only!
    http://www32.brinkster.com/srisamp

    "anders" <aa.net> wrote in message
    news:0cee01c351dd$c1cb6320$gbl... 
    > pubs.dbo.employee WHERE job_lvl = 
    > from sp_executesql. 
    > suppress the output. Is [/ref]
    > AS [/ref]
    > markt [/ref]
    > EXEC 
    > >
    > >
    > >.
    > >[/ref][/ref]


    SriSamp Guest

  3. #3

    Default Re: Dont want to see the exec sp_executesql result

    Your first dynamic query returns a rowset instead of setting TotalRecords.
    Try this:

    set subSql = 'SELECT TotalRecords = count(id) FROM ...

    "anders" <aa.net> wrote in message
    news:0b3b01c351d7$e1e7f700$gbl... 


    Anthony Guest

Similar Threads

  1. exec w. imagemagick gives incomplete result
    By Morten in forum PHP Development
    Replies: 2
    Last Post: December 19th, 10:51 AM
  2. sp_executeSql
    By Ola in forum Microsoft SQL / MS SQL Server
    Replies: 3
    Last Post: July 15th, 10:50 PM
  3. sp_executeSQL Performance in a Proc(?)
    By JDP@Work in forum Microsoft SQL / MS SQL Server
    Replies: 5
    Last Post: July 2nd, 09:22 PM
  4. Replies: 0
    Last Post: December 10th, 09:27 AM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139