SQL Syntax in commandText

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

SQL Syntax in commandText

all4gsus
I need some help with some SQL as for what is supported in regards to <commandText> section of the database target. I have a command that does multiple table inserts, but in one particular condition I want it to not insert. Please see the following:

        IF @ID IS NOT NULL AND @ID <> ''
        BEGIN
          INSERT INTO EventAttribute  ([EventID], [Attribute], [Value])
          VALUES                      (@iEventID, 'ID', @CmhcID);
        END

There is an error on encoding..The limitation for the 'not equal' <> is more of a XML encoding limitation I suppose, and for the life of me I can think of a workaround.

Thanks.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SQL Syntax in commandText

all4gsus
This post was updated on .
Found the solution just shortly after posting.... Why does that always happen to me? I'll respond in case someone else has a similar need.

All that needs to be done is use the proper xml-encoding char codes, like in HTML.


        IF @ID IS NOT NULL AND @ID \<\> \'\'
        BEGIN
          INSERT INTO EventAttribute  ([EventID], [Attribute], [Value])
          VALUES                      (@iEventID, 'ID', @CmhcID);
        END
Loading...