Showing posts with label returns. Show all posts
Showing posts with label returns. Show all posts

Friday, March 23, 2012

Noob count question

I have a table of events, which stores an event ID, event Name and event
date.
I want to write a stored procedure that returns the next 4 events starting
from today, so far I have:
SELECT
[EventID],
[EventName],
[EventDate]
FROM
Events
WHERE
(DATEDIFF(dd, GETDATE(), EventDate) > 0)
ORDER BY
[EventDate] ASC
How do I add a clause to say only return a maximum of 4 (or however many is
left if fewer) events from today?Use the TOP clause using 4 as the number of records to be returned.
Optionally SET ROWCOUNT. But TOP is preferred.
HTH
Jerry
"Seefor" <invalid@.email.address> wrote in message
news:DfBXe.111419$G8.92946@.text.news.blueyonder.co.uk...
>I have a table of events, which stores an event ID, event Name and event
>date.
> I want to write a stored procedure that returns the next 4 events starting
> from today, so far I have:
> SELECT
> [EventID],
> [EventName],
> [EventDate]
> FROM
> Events
> WHERE
> (DATEDIFF(dd, GETDATE(), EventDate) > 0)
> ORDER BY
> [EventDate] ASC
>
> How do I add a clause to say only return a maximum of 4 (or however many
> is left if fewer) events from today?
>|||many thanks
"Jerry Spivey" <jspivey@.vestas-awt.com> wrote in message
news:etg0fRTvFHA.1392@.tk2msftngp13.phx.gbl...
> Use the TOP clause using 4 as the number of records to be returned.
> Optionally SET ROWCOUNT. But TOP is preferred.
> HTH
> Jerry
> "Seefor" <invalid@.email.address> wrote in message
> news:DfBXe.111419$G8.92946@.text.news.blueyonder.co.uk...
>|||If you want to use an index on EventDate efficiently, make sure you don't
have any manipulation on the filtered column.
Instead of:
WHERE (DATEDIFF(dd, GETDATE(), EventDate) > 0)
Use:
WHERE EventDate >= CONVERT(VARCHAR(8), GETDATE(), 112)
Specify TOP 4 in the SELECT list, and sort by EventDate .
BG, SQL Server MVP
www.SolidQualityLearning.com
"Seefor" <invalid@.email.address> wrote in message
news:DfBXe.111419$G8.92946@.text.news.blueyonder.co.uk...
>I have a table of events, which stores an event ID, event Name and event
>date.
> I want to write a stored procedure that returns the next 4 events starting
> from today, so far I have:
> SELECT
> [EventID],
> [EventName],
> [EventDate]
> FROM
> Events
> WHERE
> (DATEDIFF(dd, GETDATE(), EventDate) > 0)
> ORDER BY
> [EventDate] ASC
>
> How do I add a clause to say only return a maximum of 4 (or however many
> is left if fewer) events from today?
>

Wednesday, March 7, 2012

noise words and language support

Hi,
I am using sql2000 server full-text search and neutral word braeker is set.
I am having problem with noise words becouse the sql query returns with
ignored word error.
The sql query somethink like that
SELECT title FROM tFtest WHERE contains (title,'"*nokia*" near
"*phone*" near "*-*"' )
"-" is not in ignored words and also "/ * ' " etc words give the error. I
cleared the noise.dat file and restat the mssearch but I got still the same
error. how can I avoid the error. The table rows are less than 100 thousand
so the file size is not important.
The second question is sql2000 fulltext search server doesn't support
turkish language and that is why I had to choose neutral setting. Is there
any why to use turkish language in fulltext search.
Thankstolgay wrote on Wed, 10 Oct 2007 11:54:15 +0300:
> Hi,
> I am using sql2000 server full-text search and neutral word braeker is
> set.
> I am having problem with noise words becouse the sql query returns with
> ignored word error.
> The sql query somethink like that
> SELECT title FROM tFtest WHERE contains (title,'"*nokia*" near
> "*phone*" near "*-*"' )
> "-" is not in ignored words and also "/ * ' " etc words give the
> error. I cleared the noise.dat file and restat the mssearch but I got
> still the same error. how can I avoid the error. The table rows are
> less than 100 thousand so the file size is not important.
- / * are not words. Also, you cannot use a term like *nokia* - the *
operator is for prefix searches only (eg. nokia* finds all words that start
with nokia).
Your search should look like this:
SELECT title FROM tFtest WHERE contains (title,'"nokia" near
"phone"')
Dan|||Thanks you light me up :)
I know if I erase the line the code will work but dou you know which words
cannot be used which are not in the noise.dat becouse the search text comes
from search page and user can write everythink or anythink what they want
and my code must work with out given error.
"Daniel Crichton" <msnews@.worldofspack.com> wrote in message
news:eT$KkBzCIHA.1204@.TK2MSFTNGP03.phx.gbl...
> tolgay wrote on Wed, 10 Oct 2007 11:54:15 +0300:
> > Hi,
> > I am using sql2000 server full-text search and neutral word braeker is
> > set.
> > I am having problem with noise words becouse the sql query returns with
> > ignored word error.
> > The sql query somethink like that
> > SELECT title FROM tFtest WHERE contains (title,'"*nokia*" near
> > "*phone*" near "*-*"' )
> > "-" is not in ignored words and also "/ * ' " etc words give the
> > error. I cleared the noise.dat file and restat the mssearch but I got
> > still the same error. how can I avoid the error. The table rows are
> > less than 100 thousand so the file size is not important.
>
> - / * are not words. Also, you cannot use a term like *nokia* - the *
> operator is for prefix searches only (eg. nokia* finds all words that
start
> with nokia).
> Your search should look like this:
> SELECT title FROM tFtest WHERE contains (title,'"nokia" near
> "phone"')
> Dan
>|||tolgay wrote on Wed, 10 Oct 2007 14:48:54 +0300:
> Thanks you light me up :)
> I know if I erase the line the code will work but dou you know which
> words cannot be used which are not in the noise.dat becouse the search
> text comes from search page and user can write everythink or anythink
> what they want and my code must work with out given error.
Just strip out all non-alphanumeric "words".
Dan

nocount returns rows affected

I have several sprocs that have SET NOCOUNT ON, yet still return "n row(s)
affected" when I execute the sproc. It seems to happen sporadically too.
Sometimes if I exit QA and go back in, it will execute w/o returning row
counts - other times I continue to get the number of rows affected returned.
Is this just voodoo with my system, or is there an explainable reason why
this happens?
Thanks, Andresql2k: check to see if any SET STATISTICS options are ON. [Tools \
Options \ Connection Properties]
If these affect any rows for their logging, the rowcounts are returned,
regardless of the set nocount setting.
Andre wrote:
> I have several sprocs that have SET NOCOUNT ON, yet still return "n row(s)
> affected" when I execute the sproc. It seems to happen sporadically too.
> Sometimes if I exit QA and go back in, it will execute w/o returning row
> counts - other times I continue to get the number of rows affected returne
d.
> Is this just voodoo with my system, or is there an explainable reason why
> this happens?
> Thanks, Andre
>|||In addition to what Trey said, what kind of statements are you executing?
SELECTS, UPDATES, etc? Any chance an object is being called that has SET
NOCOUNT OFF (I would rather doubt it, but never hurts to ask)
Also, does this anomoly happen on any of your procs, or just a select few?
Can you post the code, if it is just a few?
--
----
Louis Davidson - http://spaces.msn.com/members/drsql/
SQL Server MVP
"Arguments are to be avoided: they are always vulgar and often convincing."
(Oscar Wilde)
"Andre" <no@.spam.com> wrote in message
news:uby%239yLEGHA.2704@.TK2MSFTNGP15.phx.gbl...
>I have several sprocs that have SET NOCOUNT ON, yet still return "n row(s)
> affected" when I execute the sproc. It seems to happen sporadically too.
> Sometimes if I exit QA and go back in, it will execute w/o returning row
> counts - other times I continue to get the number of rows affected
> returned.
> Is this just voodoo with my system, or is there an explainable reason why
> this happens?
> Thanks, Andre
>|||It happens in all of my sprocs, but like I said - it's sporadic. For
instance, yesterday when I posted this issue, a sproc was returning rows
affected. I exited QA, went back in, and the same sproc worked w/o
returning rows affected. The set nocount on stmt has been in the sproc
forever; it wasn't just added yesterday. That's why I wonder if I have some
sort of voodoo/gremlins in my box. :)
Andre|||I hate to agree with the gremlins/voodoo diagnosis, but it does sound like
something wierd going on. Do you have this problem on any other box? Like
try it out on OSQL/SQLCMD, or on the QA on the server also (particularly if
you can do it at the same time you are having issues on your development
box)
This way you can isolate it down to the box or server. Wish there was
better advice, but you could try calling GhostBusters :)
----
Louis Davidson - http://spaces.msn.com/members/drsql/
SQL Server MVP
"Arguments are to be avoided: they are always vulgar and often convincing."
(Oscar Wilde)
"Andre" <no@.spam.com> wrote in message
news:O7U2V5TEGHA.2912@.tk2msftngp13.phx.gbl...
> It happens in all of my sprocs, but like I said - it's sporadic. For
> instance, yesterday when I posted this issue, a sproc was returning rows
> affected. I exited QA, went back in, and the same sproc worked w/o
> returning rows affected. The set nocount on stmt has been in the sproc
> forever; it wasn't just added yesterday. That's why I wonder if I have
> some
> sort of voodoo/gremlins in my box. :)
> Andre
>