Results 1 to 2 of 2

Thread: Syntaxis Error

  1. #1
    Join Date
    Jan 2003
    Posts
    14

    Post Unanswered: Syntaxis Error

    I have a problem...
    I'm trying to do this...

    declare @cmd varchar(200)
    @cmd = 'Select 1 from xx'
    if exist (exec(@cmd))
    begin
    'my code'
    end

    but I have an error..., do you know why??

  2. #2
    Join Date
    Oct 2002
    Posts
    369

    Re: Syntaxis Error

    RE:
    I have a problem...
    I'm trying to do this...

    declare @cmd varchar(200)
    @cmd = 'Select 1 from xx'
    if exist (exec(@cmd))
    begin
    'my code'
    end

    but I have an error...,
    Q1 do you know why??
    A1 Probably, however there may be several reasons.

    Three points to consider:

    a If evaluates an expression (that must produce a boolean result).

    b exist () --> exists()

    c Exists () evaluates a (valid) subquery for the existance of a result set of at least one row.

    For Example see: dba_Demo_Using_If_and_Exists_forRowExistanceTestin g.sql

Posting Permissions

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