Showing posts with label compound. Show all posts
Showing posts with label compound. Show all posts

Tuesday, March 20, 2012

Compound Statements

Hello,

How can I stop/prevent SQL server from running compound SQL
statements. I do not want the server to run multiple
update/delete/insert/select statements as a batch. Is there an option?

/Kaf
www.afiouni.comKhaled Afiouni (post@.afiouni.com) writes:
> How can I stop/prevent SQL server from running compound SQL
> statements. I do not want the server to run multiple
> update/delete/insert/select statements as a batch. Is there an option?

No, there is no such option.

Please explain what your real problem is, and maybe we can find a
suggestion. What you are asking for right now does not really make sense?

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||The usual mechanism to restrict what operations users can perform is to give
them access only through parameterized stored procedures. Does that not meet
your requirements?

--
David Portas
SQL Server MVP
--|||Erland Sommarskog <esquel@.sommarskog.se> wrote in message news:<Xns951F7F821DCD5Yazorman@.127.0.0.1>...
> Khaled Afiouni (post@.afiouni.com) writes:
> > How can I stop/prevent SQL server from running compound SQL
> > statements. I do not want the server to run multiple
> > update/delete/insert/select statements as a batch. Is there an option?
> No, there is no such option.
> Please explain what your real problem is, and maybe we can find a
> suggestion. What you are asking for right now does not really make sense?

Thank you for your reply. Please allow me to simplify it.

Actually I am checking for an ultimate solution to the SQL injection
issues. So in addition to filtering, checking and validating the
input, I would like to stop the compound statements from running and
allowing only the first SQL statements to be executed.

Any suggestions?

/Kaf
www.afiouni.com|||Erland Sommarskog <esquel@.sommarskog.se> wrote in message news:<Xns951F7F821DCD5Yazorman@.127.0.0.1>...
> Khaled Afiouni (post@.afiouni.com) writes:
> > How can I stop/prevent SQL server from running compound SQL
> > statements. I do not want the server to run multiple
> > update/delete/insert/select statements as a batch. Is there an option?
> No, there is no such option.
> Please explain what your real problem is, and maybe we can find a
> suggestion. What you are asking for right now does not really make sense?

Thank you very much for your reply.

I am trying to find an ultimate solution to the SQL injection issues.
In addition to verifying, validating and checking on the data entry
fields, I would like to prevent compound statements from running and
only allowing the first SQL statement to run.

Any Suggestions?

/Kaf
www.afiouni.com|||>> Actually I am checking for an ultimate solution to the SQL injection
issues. <<

Never write dynamic SQL; learn how to program correctly instead. This
is part of any basic Software Engineering course.

--CELKO--
===========================
Please post DDL, so that people do not have to guess what the keys,
constraints, Declarative Referential Integrity, datatypes, etc. in your
schema are.

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!|||Khaled Afiouni (post@.afiouni.com) writes:
> I am trying to find an ultimate solution to the SQL injection issues.
> In addition to verifying, validating and checking on the data entry
> fields, I would like to prevent compound statements from running and
> only allowing the first SQL statement to run.

To do that you would have to add some middleware and have all your
clients talk to that middleware, and this middleware would pass the
code to SQL Server after validation and then pass the data back.

Not for the faint of heart. And it would be a reduction in usability,
since there sometimes be very good reason for an application to submit
two commands one go.

And you would not even be safe. You could intercept dynamic SQL created
client side, but not dynamic SQL created in stored procedures.

First step, is to let the users run the application with as few permissions
as possible. Ideally, all access should be through stored procedures, and
there should not be any dynamic SQL in the SPs as well. The users only
needs EXEC permission to the procedures. Now, this may hamper usability,
since some functions are easier to implement with dynamic SQL, not the
least if you want performance. (Typically this is search functions where
the users can search on a number of criterias.) But if you restrict
access to SELECT on the table, an intruder cannot wreck your database.

Next step is to write the SQL code properly. If you are constructing
SQL code client-side, use prepared statements with placeholds for
the parameters. Never build the entire string with values and all.
You can also call sp_executesql directly through RPC methods, *not*
as EXEC statements!

If you use dynamic SQL in stored procedures, use sp_executesql to run
your dynamic SQL, not EXEC().

For dynamic SQL on the client side, I have some articles on my web site:
http://www.sommarskog.se/dynamic_sql.html
http://www.sommarskog.se/dyn-search.html

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||After following this thread for a few go-rounds, perhaps it is worth asking,
what is it that you are trying to achieve by stopping such compound
commands?
In particular, why is there SQL outside your control being posted to your
server?
No criticism of your system, just feels like your respondents could use a
"bigger picture".

"Khaled Afiouni" <post@.afiouni.com> wrote in message
news:a5c90178.0407070152.17be0506@.posting.google.c om...
> Hello,
> How can I stop/prevent SQL server from running compound SQL
> statements. I do not want the server to run multiple
> update/delete/insert/select statements as a batch. Is there an option?
> /Kaf
> www.afiouni.com|||Erland Sommarskog <esquel@.sommarskog.se> wrote in message news:<Xns951FEBF2D734Yazorman@.127.0.0.1>...
> Khaled Afiouni (post@.afiouni.com) writes:
> > I am trying to find an ultimate solution to the SQL injection issues.
> > In addition to verifying, validating and checking on the data entry
> > fields, I would like to prevent compound statements from running and
> > only allowing the first SQL statement to run.
> To do that you would have to add some middleware and have all your
> clients talk to that middleware, and this middleware would pass the
> code to SQL Server after validation and then pass the data back.
> Not for the faint of heart. And it would be a reduction in usability,
> since there sometimes be very good reason for an application to submit
> two commands one go.
> And you would not even be safe. You could intercept dynamic SQL created
> client side, but not dynamic SQL created in stored procedures.
> First step, is to let the users run the application with as few permissions
> as possible. Ideally, all access should be through stored procedures, and
> there should not be any dynamic SQL in the SPs as well. The users only
> needs EXEC permission to the procedures. Now, this may hamper usability,
> since some functions are easier to implement with dynamic SQL, not the
> least if you want performance. (Typically this is search functions where
> the users can search on a number of criterias.) But if you restrict
> access to SELECT on the table, an intruder cannot wreck your database.
> Next step is to write the SQL code properly. If you are constructing
> SQL code client-side, use prepared statements with placeholds for
> the parameters. Never build the entire string with values and all.
> You can also call sp_executesql directly through RPC methods, *not*
> as EXEC statements!
> If you use dynamic SQL in stored procedures, use sp_executesql to run
> your dynamic SQL, not EXEC().
> For dynamic SQL on the client side, I have some articles on my web site:
> http://www.sommarskog.se/dynamic_sql.html
> http://www.sommarskog.se/dyn-search.html

Thank you for taking the time to write that helpfull reply. I appreciate it.

/Kaf
www.afiouni.com|||"Mischa Sandberg" <mischa_sandberg@.telus.net> wrote in message news:<km1Hc.11732$eO.2611@.edtnps89>...
> After following this thread for a few go-rounds, perhaps it is worth asking,
> what is it that you are trying to achieve by stopping such compound
> commands?
> In particular, why is there SQL outside your control being posted to your
> server?
> No criticism of your system, just feels like your respondents could use a
> "bigger picture".
> "Khaled Afiouni" <post@.afiouni.com> wrote in message
> news:a5c90178.0407070152.17be0506@.posting.google.c om...
> > Hello,
> > How can I stop/prevent SQL server from running compound SQL
> > statements. I do not want the server to run multiple
> > update/delete/insert/select statements as a batch. Is there an option?
> > /Kaf
> > www.afiouni.com

You are absolutely right. Allow me to share those documents with
everybody.

cnscenter.future.co.kr/resource/rsc-center/vendor-wp/Spidynamics/WhitepaperSQLInjection2.pdf

http://jo.morales0002.eresmas.net/o...QLInjection.pdf

This issue can get scary especially that I did see it in action :-)

/Kaf
www.afiouni.com|||Joe Celko <jcelko212@.earthlink.net> wrote in message news:<40ec4e5d$0$16505$c397aba@.news.newsgroups.ws>...
> >> Actually I am checking for an ultimate solution to the SQL injection
> issues. <<
> Never write dynamic SQL; learn how to program correctly instead. This
> is part of any basic Software Engineering course.
> --CELKO--
> ===========================
> Please post DDL, so that people do not have to guess what the keys,
> constraints, Declarative Referential Integrity, datatypes, etc. in your
> schema are.
> *** Sent via Devdex http://www.devdex.com ***
> Don't just participate in USENET...get rewarded for it!

O:-)

/Kaf
www.afiouni.com|||I used to work for Simba.com (now owned by Orbital.com). Simba produced the
SQL engine/driver kit behind about half the ODBC drivers in the world.

We had a tiny ODBC proxy driver that did more or less what you were asking.
It received the SQL commands, applied the engine's parser to them, did some
rulechecking/rewriting of the parse tree based on the customer's
requirements, and either responded with an error, or forwarded the parse
tree (collapsed back to a command string) to the REAL ODBC connection.

You may want to check with Orbital on that.

"Khaled Afiouni" <post@.afiouni.com> wrote in message ...
cnscenter.future.co.kr/resource/rsc-center/vendor-wp/Spidynamics/WhitepaperS
QLInjection2.pdf
> http://jo.morales0002.eresmas.net/o...QLInjection.pdf
> This issue can get scary especially that I did see it in action :-)
> /Kaf
> www.afiouni.com

Compound Primary Key - order not as expected

Hello,

if you create this table:

create table hello (
int a
, int b
constraint pk_hello primary key clustered ( a, b )
)

and then insert the following records

a,b
1,1
1,2
1,3
2,1
2,2
2,3
3,1
3,2
3,3

and then do

select a,b from hello

the output seems to be:

a,b
1,1
2,1
3,1
1,2
2,2
3,2
1,3
2,3
3,3

which is wrong and (i think) is reflecting the actual index order
and physical order on disk

it should be:

a,b
1,1
1,2
1,3
2,1
2,2
2,3
3,1
3,2
3,3

i have tested this on a table with 500,000 records

and sure enough if you declare the clustered primary key fields in
reverse order:

constraint pk_hello primary key clustered ( b, a )

two things happen:

- the select with no order by returns the records in the expected order
- queries relying on that order run MUCH FASTER

has anyone else seen / noticed this?John Rivers wrote:
> Hello,
> if you create this table:
> create table hello (
> int a
> , int b
> constraint pk_hello primary key clustered ( a, b )
> )
> and then insert the following records
> a,b
> 1,1
> 1,2
> 1,3
> 2,1
> 2,2
> 2,3
> 3,1
> 3,2
> 3,3
> and then do
> select a,b from hello
> the output seems to be:
> a,b
> 1,1
> 2,1
> 3,1
> 1,2
> 2,2
> 3,2
> 1,3
> 2,3
> 3,3
> which is wrong and (i think) is reflecting the actual index order
> and physical order on disk

This is not wrong at all. As long as you do not have an "ORDER BY"
clause the RDBMS is free to return records in *any* order.

> it should be:
> a,b
> 1,1
> 1,2
> 1,3
> 2,1
> 2,2
> 2,3
> 3,1
> 3,2
> 3,3
> i have tested this on a table with 500,000 records
> and sure enough if you declare the clustered primary key fields in
> reverse order:
> constraint pk_hello primary key clustered ( b, a )
> two things happen:
> - the select with no order by returns the records in the expected order

Again: you have to adjust your expectations.

> - queries relying on that order run MUCH FASTER
> has anyone else seen / noticed this?

Yes.

Cheers

robert|||Order is not guaranteed unless you include an ORDER BY. This is by design.

--
Tom

----------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Toronto, ON Canada
..
"John Rivers" <first10@.btinternet.com> wrote in message
news:1146048739.469710.138210@.e56g2000cwe.googlegr oups.com...
Hello,

if you create this table:

create table hello (
int a
, int b
constraint pk_hello primary key clustered ( a, b )
)

and then insert the following records

a,b
1,1
1,2
1,3
2,1
2,2
2,3
3,1
3,2
3,3

and then do

select a,b from hello

the output seems to be:

a,b
1,1
2,1
3,1
1,2
2,2
3,2
1,3
2,3
3,3

which is wrong and (i think) is reflecting the actual index order
and physical order on disk

it should be:

a,b
1,1
1,2
1,3
2,1
2,2
2,3
3,1
3,2
3,3

i have tested this on a table with 500,000 records

and sure enough if you declare the clustered primary key fields in
reverse order:

constraint pk_hello primary key clustered ( b, a )

two things happen:

- the select with no order by returns the records in the expected order
- queries relying on that order run MUCH FASTER

has anyone else seen / noticed this?|||Let's get back to the basics of an RDBMS. Rows are not records; fields
are not columns; tables are not files; there is no sequential access or
ordering in an RDBMS, so "first", "next" and "last" are totally
meaningless. If you want an ordering, then you need to have a column
that defines that ordering. You must use an ORDER BY clause on a
cursor or in an OVER() clause.

You need to read a book on RDBMS; you are still locked into a file
system mind set.|||Hello,

when a clustered index is present the records *are* physically ordered
on disk to match the index

that is the whole point of a clustered index

and by default a select statement with no ORDER BY will always return
data in the order of the clustered index (when present)

this can easily be proved by watching the Execution Plan

the issue i am trying to highlight concerns the order of the records on
disk when a *compound* clustered index is present

i have seen cases when it is not as expected

maybe you can enjoy reading that RDBMS book :-)

best wishes,

john|||John Rivers wrote:
> Hello,
> when a clustered index is present the records *are* physically ordered
> on disk to match the index
> that is the whole point of a clustered index
> and by default a select statement with no ORDER BY will always return
> data in the order of the clustered index (when present)
Um. No. I've seen it return them out of order with only a few hundred
rows. As soon as the table is occupying more than one page, the query
optimizer *can* decide to produce a parallel plan. You'll see the
result as chunks of output which are in clustered index order, but no
deterministic ordering between the chunks. e.g. it'll look like:

1
2
3
4
5
11
12
13
14
15
6
7
8
9
10

The *only* way to guarantee the order of output is to put an order by
clause on your select statement.

Damien|||John Rivers wrote:
> and by default a select statement with no ORDER BY will always return
> data in the order of the clustered index (when present)

Not true at all. As Joe says, tables are not logically ordered. There
is no guarantee that any queries will match the physical order on disk
or in a clustered index.

--
David Portas, SQL Server MVP

Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.

SQL Server Books Online:
http://msdn2.microsoft.com/library/...US,SQL.90).aspx
--|||On 28 Apr 2006 05:41:26 -0700, John Rivers wrote:

>Hello,
>when a clustered index is present the records *are* physically ordered
>on disk to match the index
>that is the whole point of a clustered index

Hi John,

Correct.

>and by default a select statement with no ORDER BY will always return
>data in the order of the clustered index (when present)

Incorrect. Damien already pointed out the risk of parallellism.

Another potential issue is an optimization technique MS employs called
"piggybacking" - if a query on another connection is in the middle of a
tbale scan on the table you need, the DB will use the values coming in
for your query as well, then (when the first query's table scan is
finished) restart the scan from start up to where it started to
piggyback. The results would be like 6 - 7 - 8 - 9 - 10 - 1 - 2 - 3 - 4
- 5

This is almost impossible to reproduce in a test environment, but it
MIGHT happen intermittently in a heavily used production DB. Tough lluck
if your app expects the rows to be in order, even without ORDER BY.

>the issue i am trying to highlight concerns the order of the records on
>disk when a *compound* clustered index is present
>i have seen cases when it is not as expected

How did you "see" those cases? Using a query reallly doesn't prove
anything. Did you issue DBCC PAGE commands to inspect the actual
contents of the index and data pages?

--
Hugo Kornelis, SQL Server MVP|||John Rivers (first10@.btinternet.com) writes:
> when a clustered index is present the records *are* physically ordered
> on disk to match the index
> that is the whole point of a clustered index

Actually, they are ordered if you follow the page links. But if pages
are in disorder, the physical order on disk may be yet another one.

> and by default a select statement with no ORDER BY will always return
> data in the order of the clustered index (when present)

No. This may have been true by chance for SQL Server up version 6.5. It is
definitely not correct for SQL 7 and later.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||Thanks for your knowledgable answers

I will check out DBCC PAGE

Compound Primary Key - How to ?

I need to know how to create a compound primary key in Transact-SQL
It's really simple, it's a table with 3 column, two of those make the primary key Right now the CREATE TABLE look like this:
/* SectionsContent Table */
CREATE TABLE SectionsContent (
SectionID Int NOT NULL
CONSTRAINT FK_SectionsContent_SectionID FOREIGN KEY
REFERENCES PsychoCMS.dbo.Sections(ID),
DocumentID Int NOT NULL
CONSTRAINT FK_SectionsContent_DocumentID FOREIGN KEY
REFERENCES PsychoCMS.dbo.Documents(ID),
Position int NOT NULL
)

Can anyone help me ?One of my tricks to figure out how to do stuff like this is use Enterprise Manager to build it and then have it generate a script. You get something like this for the primary key part of the table:

ALTER TABLE [dbo].[titleauthor] ADD
CONSTRAINT [UPKCL_taind] PRIMARY KEY CLUSTERED
(
[au_id],
[title_id]
) ON [PRIMARY]
GOsqlsql

Compound IIF Statement

The compound statement:
=Iif(DateDiff("d", Fields!TranDate.Value, Parameters!AgeDate.Value) > 30 &
DateDiff("d", Fields!TranDate.Value, Parameters!AgeDate.Value) < 61,
Fields!Amount.Value, "")
The purpose of the above statement is to print the "Amount.Value" if the #
of days is greater than 30 and less than 61. The problem is that it prints
the value "Amount.Value" and ignores the actual # of days. IE, if the
difference in the dates is 15, "Amount.Value" is printed. Is this syntax
correct? Can you have compound statements using DateDiff?
Thanks,
JohnYou are using & instead of AND. & is appending the two values together
instead of doing a boolean compare.
Oh, you can definitely have compound iif statements but you are not doing
that. A compound iif would be iif(some boolean expression, true value,
iif(blah, blah, blah))
--
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"John Joslin" <JohnJoslin@.discussions.microsoft.com> wrote in message
news:945474CD-1373-43E4-AD35-01DBCF3671FF@.microsoft.com...
> The compound statement:
> =Iif(DateDiff("d", Fields!TranDate.Value, Parameters!AgeDate.Value) > 30 &
> DateDiff("d", Fields!TranDate.Value, Parameters!AgeDate.Value) < 61,
> Fields!Amount.Value, "")
> The purpose of the above statement is to print the "Amount.Value" if the #
> of days is greater than 30 and less than 61. The problem is that it prints
> the value "Amount.Value" and ignores the actual # of days. IE, if the
> difference in the dates is 15, "Amount.Value" is printed. Is this syntax
> correct? Can you have compound statements using DateDiff?
> Thanks,
> John|||Thanks Bruce! It works very nicely now...
"Bruce L-C [MVP]" wrote:
> You are using & instead of AND. & is appending the two values together
> instead of doing a boolean compare.
> Oh, you can definitely have compound iif statements but you are not doing
> that. A compound iif would be iif(some boolean expression, true value,
> iif(blah, blah, blah))
> --
> Bruce Loehle-Conger
> MVP SQL Server Reporting Services
> "John Joslin" <JohnJoslin@.discussions.microsoft.com> wrote in message
> news:945474CD-1373-43E4-AD35-01DBCF3671FF@.microsoft.com...
> > The compound statement:
> >
> > =Iif(DateDiff("d", Fields!TranDate.Value, Parameters!AgeDate.Value) > 30 &
> > DateDiff("d", Fields!TranDate.Value, Parameters!AgeDate.Value) < 61,
> > Fields!Amount.Value, "")
> >
> > The purpose of the above statement is to print the "Amount.Value" if the #
> > of days is greater than 30 and less than 61. The problem is that it prints
> > the value "Amount.Value" and ignores the actual # of days. IE, if the
> > difference in the dates is 15, "Amount.Value" is printed. Is this syntax
> > correct? Can you have compound statements using DateDiff?
> >
> > Thanks,
> >
> > John
>
>

compound iif query

I have the following query
= "SELECT * FROM "
& IIf(Parameters!ar.Value = "renewal", "vwRenewal", "vwOPL"
& " Where 0=0 "
& IIf(Parameters!ar.value = "renewal", "AND (IIf(boolExtension = 1),
(dateEXTENSIONDATE >= '" & Parameters!begindate.Value & "') AND
(dateEXTENSIONDATE <= '" & Parameters!enddate.Value & "'), "")", "")
There is a lot more to this query, but basicaly everything works except the
above line. I want to say that if the ar=renewal and the boolextension is 1
then choose those dates, ortherwise choose everything as it should be. what
is wrong with this line I am getting an incorrect syntax error.The best way to track this down is to assign this to a textbox and see what
you get (I sometimes create a barebones report with only the parameters and
the textbox, no datasets). That is how I handle the problem.
Bruce L-C
"MallTLC" <MallTLC@.discussions.microsoft.com> wrote in message
news:FBC8D622-F1FD-40E2-AE97-12D9CB0EB608@.microsoft.com...
> I have the following query
> = "SELECT * FROM "
> & IIf(Parameters!ar.Value = "renewal", "vwRenewal", "vwOPL"
> & " Where 0=0 "
> & IIf(Parameters!ar.value = "renewal", "AND (IIf(boolExtension = 1),
> (dateEXTENSIONDATE >= '" & Parameters!begindate.Value & "') AND
> (dateEXTENSIONDATE <= '" & Parameters!enddate.Value & "'), "")", "")
> There is a lot more to this query, but basicaly everything works except
the
> above line. I want to say that if the ar=renewal and the boolextension is
1
> then choose those dates, ortherwise choose everything as it should be.
what
> is wrong with this line I am getting an incorrect syntax error.|||So I should be able to create compound iifs on the query page, correct.
"Bruce Loehle-Conger" wrote:
> The best way to track this down is to assign this to a textbox and see what
> you get (I sometimes create a barebones report with only the parameters and
> the textbox, no datasets). That is how I handle the problem.
> Bruce L-C
> "MallTLC" <MallTLC@.discussions.microsoft.com> wrote in message
> news:FBC8D622-F1FD-40E2-AE97-12D9CB0EB608@.microsoft.com...
> > I have the following query
> >
> > = "SELECT * FROM "
> >
> > & IIf(Parameters!ar.Value = "renewal", "vwRenewal", "vwOPL"
> >
> > & " Where 0=0 "
> >
> > & IIf(Parameters!ar.value = "renewal", "AND (IIf(boolExtension = 1),
> > (dateEXTENSIONDATE >= '" & Parameters!begindate.Value & "') AND
> > (dateEXTENSIONDATE <= '" & Parameters!enddate.Value & "'), "")", "")
> >
> > There is a lot more to this query, but basicaly everything works except
> the
> > above line. I want to say that if the ar=renewal and the boolextension is
> 1
> > then choose those dates, ortherwise choose everything as it should be.
> what
> > is wrong with this line I am getting an incorrect syntax error.
>
>|||Anything you can do with an expression you can do anywhere an expression is
used. Compounded iif's are 100% fine to do. They are confusing but fine. The
expression evaluation is no different if you are using it for the source of
a dataset or you are using it as the source of a textbox. So you can cut and
paste your expression into the source for a textbox. Right mouse click on
textbox, expression. Then paste the expression into the right side.
Bruce L-C
"MallTLC" <MallTLC@.discussions.microsoft.com> wrote in message
news:52404738-D383-4E63-B36A-23BE6E6B4EFB@.microsoft.com...
> So I should be able to create compound iifs on the query page, correct.
> "Bruce Loehle-Conger" wrote:
> > The best way to track this down is to assign this to a textbox and see
what
> > you get (I sometimes create a barebones report with only the parameters
and
> > the textbox, no datasets). That is how I handle the problem.
> >
> > Bruce L-C
> >
> > "MallTLC" <MallTLC@.discussions.microsoft.com> wrote in message
> > news:FBC8D622-F1FD-40E2-AE97-12D9CB0EB608@.microsoft.com...
> > > I have the following query
> > >
> > > = "SELECT * FROM "
> > >
> > > & IIf(Parameters!ar.Value = "renewal", "vwRenewal", "vwOPL"
> > >
> > > & " Where 0=0 "
> > >
> > > & IIf(Parameters!ar.value = "renewal", "AND (IIf(boolExtension = 1),
> > > (dateEXTENSIONDATE >= '" & Parameters!begindate.Value & "') AND
> > > (dateEXTENSIONDATE <= '" & Parameters!enddate.Value & "'), "")", "")
> > >
> > > There is a lot more to this query, but basicaly everything works
except
> > the
> > > above line. I want to say that if the ar=renewal and the
boolextension is
> > 1
> > > then choose those dates, ortherwise choose everything as it should be.
> > what
> > > is wrong with this line I am getting an incorrect syntax error.
> >
> >
> >