i have this stored procedure:
@onde CHAR(100) = NULL,
@quandoinicio CHAR(100) = NULL,
@quandofim CHAR(100) = NULL,
@quantominimo CHAR(100) = NULL,
@quantomaximo CHAR(100) = NULL,
@quartos CHAR(100) = NULL,
@pessoas CHAR(100) = NULL,
@tipo CHAR(100) = NULL,
@rcama CHAR(100) = NULL,
@rbanho CHAR(100) = NULL,
@limpeza CHAR(100) = NULL,
@maqloica CHAR(100) = NULL,
@maqroupa CHAR(100) = NULL,
@arcon CHAR(100) = NULL,
@satcabo CHAR(100) = NULL,
@internet CHAR(100) = NULL,
@barbecue CHAR(100) = NULL,
@formpesqavancadabut CHAR(100) = NULL
AS
BEGIN
SET NOCOUNT ON;
SELECT distinct
cod_casa,destino,data_activo,tipo,pessoas,localidade,img_1,img_2 ,img_3,
img_4,data_act, certif,valor_voto,n_voto
FROM
pesq_1_com_feedback
WHERE
((@onde IS NULL) OR (localidade = @onde))
AND ((@quandoinicio IS NULL) OR (inicio >= @quandoinicio))
AND ((@quandofim IS NULL) OR (fim <= @quandofim))
AND ((@quantominimo IS NULL) OR (preco > @quantominimo ))
AND ((@quantomaximo IS NULL) OR (preco < @quantomaximo ))
AND ((@quartos IS NULL) OR (quartos = @quartos ))
AND ((@pessoas IS NULL) OR (pessoas = @pessoas ))
AND ((@tipo IS NULL) OR (tipo = @tipo ))
AND ((@rcama IS NULL) OR (roupascama = @rcama ))
AND ((@rbanho IS NULL) OR (roupasbanho = @rbanho ))
AND ((@limpeza IS NULL) OR (limpeza = @limpeza ))
AND ((@maqloica IS NULL) OR (mlavaloica = @maqloica ))
AND ((@maqroupa IS NULL) OR (mlavaroupa = @maqroupa ))
AND ((@arcon IS NULL) OR (ar_condicionado = @arcon))
AND ((@satcabo IS NULL) OR (satcabo = @satcabo))
AND ((@internet IS NULL) OR (internet = @internet))
AND ((@barbecue IS NULL) OR (barbecue = @barbecue))
i have availibility calendar that have rows with
startdate and end date:
select startdate,enddate where cod_casa="record from the first select"
and livre=0
it is possible to loop between startdate to enddate?
as i do do while not rs2.eof
for k = cdate(rs2("startdate")) to cdate(rs2("enddate"))
i'm not experienced, but this loops in asp become slow and i think
treres a way to do it in sql server
"led" <l.r...@sapo.pt> wrote in message
news:e5$evpVgK...@TK2MSFTNGP02.phx.gbl...
Well, you don't really loop in SQL. But say that you have an orders
table, and you want show the numbers of orders as defined by a
calender table. That is, you only want to show data for the days
in that table. Then you would do:
SELECT C.OrderDate, COUNT(O.OrderDate)
FROM Calender C
LEFT JOIN Order O ON C.Date = O.OrderDate
GROUP BY C.OrderDate
I can't give an example for you procedure, because I don't really see
how your available calender fits into your query, but hopefully this
helps you to get going.
--
Erland Sommarskog, SQL Server MVP, esq...@sommarskog.se
Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
If you don't know anything about RDBMS, then get a copy of the
simplest intro book I know --
http://www.amazon.com/Manga-Guide-Databases-Mana-Takahashi/dp/1593271905
--
Kevin G. Boles
Indicium Resources, Inc.
SQL Server MVP
kgboles a earthlink dt net
"--CELKO--" <jcel...@earthlink.net> wrote in message
news:50257da0-f13d-4bca...@v30g2000yqm.googlegroups.com...
You appear to be posting on the wrong forum.
SQL Server does have loops, it does have sequential access, it has xml, it
has unstructured search, it has mdx, it has dmx, it has .... well, a ton of
other stuff.
If you don't know anything about SQL Server (remember - this forum is for
users of SQL Server) then check out books online which can be easily found
on the internet.
--ROGGIE--
"--CELKO--" <jcel...@earthlink.net> wrote in message
news:50257da0-f13d-4bca...@v30g2000yqm.googlegroups.com...
The other day you said:
> There is a WHILE loop in T-SQL last time I looked. Does the T-SQL
> compiler remove invariant expressions in the WHILE loop? Does the T-SQL
> compiler unroll a WHILE loop (granted that is easier with a counting
> loop)?
While there are no loops in SQL, you still care about whether SQL Server
unrolls them!
Must be his age now Erland.
But this is getting very serious now; its confusing the hell out of people
just wanting to use what is in the product and don't care about portability.
Tony.
"Erland Sommarskog" <esq...@sommarskog.se> wrote in message
news:Xns9CEA2357...@127.0.0.1...
You knew exactly what I was saying. Come on, I expect this kind of
stupid sniping from Tony. You are usually better.
I "snipe"
You "troll"
We are as bad as each other ;)
Perhaps you might want to consider this is a MICROSOFT SQL SERVER forum, not
a general "SQL" forum; there is a forum for that somewhere else - it gets
about 10 posts per month!
--ROGGIE--
"--CELKO--" <jcel...@earthlink.net> wrote in message
news:cff2f152-ba33-459b...@m26g2000yqb.googlegroups.com...
In this newsgroup it is.
> The --CLEKO-- troll is getting more and more extreme and off topic for
> this
> Microsoft SQL Server forum.
>
> Must be his age now Erland.
>
> But this is getting very serious now; its confusing the hell out of people
>
> just wanting to use what is in the product and don't care about
> portability.
As I remember he was pretty intolerable around this time of year last
year...more so than usual. I do worry about his liver....
A programmer would have be in a very small isolated environment to
deal with one and only one SQL product. DB2 and Oracle are the big
two; MySQL and LAMP rules the web; Teradata dominates data
warehousing; some really good SQLs have niches. Tony, you will not
fall off the edge of the World when you leave your village.
Like most Cowboy Coders, you think that portability is only across SQL
products; it is across releases of the same product. The Pros that
wrote to Standards were not screwed changes that brought SQL Server in
that direction.
If you want to have a specialization in a dialect, that is fine. Good
tool. I use my math for BI. But a cowboy will try to lock his client
into dialect for HIS job security and not the long-term good of the
client. A professional SQL programmer ought to know the difference and
be able to justify and document his choices when he picks dialect over
standards.
Much of my work is to make SQL portable. I work for companies that
need to run on multiple hardware and software platforms. They are
growing. Your work seems to be keeping your clients away from the
version of SQL Server the you know.
The professional also ought to have a theoretical model (what I call a
mindset) so he has a higher abstraction of the problems and the
solutions.
Perhaps then you'll stop posting drivel that doesn't even work on this
product like YYYY-MM-DD, like the way the internals of this product work
(one pass compile etc..) etc....
Don't worry --CKELO-- I've got 5 years DB2, ok - 3 months Oracle, and I'll
be learning Teradata on the masters degree in BI that I'm starting in
January - hardly a one trick pony!
I'm fully aware of what's what give my 23+ experience within IT, at the coal
face rather than in some 4 walled classroom turning hearsay into fact.
Portability died a long time ago - its not that often you come across
anybody who cares about it, heard of it and much less actually doing a
project with that as a deliverable - remember, I'm working day in, day out
with multiple clients and also have my source from the user group I run - a
user group of a good few thousand people here in the UK - so I know what is
what; but do you? I suspect not; but you'll only know that yourself ;).
--ROGGIE--
"--CELKO--" <jcel...@earthlink.net> wrote in message
news:4100c79e-fee5-4ce7...@k17g2000yqh.googlegroups.com...
The system I work is by means nowhere close to small. And in runs on
SQL Server only.
The size of the system may be different for other SQL programmers, but
most programmers only work with one product at a time. And to be able
to get the best performance out of their system, they need to know the
product they work with.
Sure, sometimes people cross borders. We had a guy that joined our team
that had a long experience of Oracle. A brave step, but there was no
happy ending. He was mainly grumpy and whined about SQL Server not doing
things he was used to, and he left after two years.
That is a patently wrong statement whether we are talking TSQL or your
beloved ANSI SQL.
--
Kevin G. Boles
Indicium Resources, Inc.
SQL Server MVP
kgboles a earthlink dt net
"--CELKO--" <jcel...@earthlink.net> wrote in message
news:cff2f152-ba33-459b...@m26g2000yqb.googlegroups.com...