Showing posts with label order. Show all posts
Showing posts with label order. Show all posts

Monday, March 26, 2012

Numbering

I have a table with Employees, and the month and year they started. I need to number them in order of the month and year they started. Example: July 2001 is employee 1 and August 2001 is employee 2. However there may be multiple employees in a given month and year. It seems like this should be a simple task but I can not figure it out. I have a query that puts them in the right order but not sure how to update the ID with the correct number. I'm using Microsoft Access 2002.

Thanks

TheAceManPlease post that query. Also, what are the data types for month and year?sql

number rows

I have wrote a query that returns product details for all orders that are at stage 6. Is there a way to number the product lines in each order no?!

Eg.
Order 1
Product 1 - 1
Product 2 - 2
Product 3 - 3

--counter restarts
Order 2
Product 1 - 1
Product 2 -2

thanks?If you are using SQL 2005, you could look into using the ROW_NUMBER function with the PARTITION BY option.|||Or you can just let the front end do it..or insert the rows into a temp table with an identity column then select from that

number of tempdb files?

On a 4 dual core, hyper threading server, how many tempdb files I should
configure in order to reduce schema lock contention? 8, or 16? I see 16
processors on the Task Manager. According to some articles dual-core CPU is
considered to be two CPUs. What about hyper-threading?
Thanks,
Lijun1) Consider (and test) turning off hyperthreading.
2) I would go with either 4 or 8 files for your tempdb, one per each true
cpu or one per core. I have seen guidance for one per cpu, but don't know
how the shared cache would really play out with dual core. Gut feeling is 4
would be best.
--
TheSQLGuru
President
Indicium Resources, Inc.
"Lijun Zhang" <sonyzhang00@.yahoo.com> wrote in message
news:u5ijH7phHHA.4904@.TK2MSFTNGP05.phx.gbl...
> On a 4 dual core, hyper threading server, how many tempdb files I should
> configure in order to reduce schema lock contention? 8, or 16? I see 16
> processors on the Task Manager. According to some articles dual-core CPU
> is
> considered to be two CPUs. What about hyper-threading?
> Thanks,
> Lijun
>

number of tempdb files?

On a 4 dual core, hyper threading server, how many tempdb files I should
configure in order to reduce schema lock contention? 8, or 16? I see 16
processors on the Task Manager. According to some articles dual-core CPU is
considered to be two CPUs. What about hyper-threading?
Thanks,
Lijun1) Consider (and test) turning off hyperthreading.
2) I would go with either 4 or 8 files for your tempdb, one per each true
cpu or one per core. I have seen guidance for one per cpu, but don't know
how the shared cache would really play out with dual core. Gut feeling is 4
would be best.
TheSQLGuru
President
Indicium Resources, Inc.
"Lijun Zhang" <sonyzhang00@.yahoo.com> wrote in message
news:u5ijH7phHHA.4904@.TK2MSFTNGP05.phx.gbl...
> On a 4 dual core, hyper threading server, how many tempdb files I should
> configure in order to reduce schema lock contention? 8, or 16? I see 16
> processors on the Task Manager. According to some articles dual-core CPU
> is
> considered to be two CPUs. What about hyper-threading?
> Thanks,
> Lijun
>

number of tempdb files?

On a 4 dual core, hyper threading server, how many tempdb files I should
configure in order to reduce schema lock contention? 8, or 16? I see 16
processors on the Task Manager. According to some articles dual-core CPU is
considered to be two CPUs. What about hyper-threading?
Thanks,
Lijun
1) Consider (and test) turning off hyperthreading.
2) I would go with either 4 or 8 files for your tempdb, one per each true
cpu or one per core. I have seen guidance for one per cpu, but don't know
how the shared cache would really play out with dual core. Gut feeling is 4
would be best.
TheSQLGuru
President
Indicium Resources, Inc.
"Lijun Zhang" <sonyzhang00@.yahoo.com> wrote in message
news:u5ijH7phHHA.4904@.TK2MSFTNGP05.phx.gbl...
> On a 4 dual core, hyper threading server, how many tempdb files I should
> configure in order to reduce schema lock contention? 8, or 16? I see 16
> processors on the Task Manager. According to some articles dual-core CPU
> is
> considered to be two CPUs. What about hyper-threading?
> Thanks,
> Lijun
>
sql

Wednesday, March 7, 2012

NULL values handled differently in stored procedure

Can someone explain why the following is happening:
SELECT EventId, MDResponse FROM tblEvent
WHERE (MDResponse NOT IN(1, 3))
ORDER BY MDResponse
If I run the above statement in Query Analyzer it returns
all rows where MDResponse is not 1 or 3. No NULL
MDResponse rows are returned. This is what I expected.
If I run it as a stored procedure it also returns the
NULL valued rows.
Why the difference?
Thanks
MikeLooks like your SP was created with the setting SET ANSI_NULLS OFF. The
setting is persisted with the SP.
Re-create the proc with SET ANSI_NULLS ON:
SET ANSI_NULLS ON
GO
CREATE PROC ...
--
David Portas
SQL Server MVP
--|||It's possible this is due to the infamous ANSI-NULL handling, which the
analyzer sets to a default value that is different than the server itself
(IIRC). For instance the analyzer will handle xxx != null, whereas that will
fail in a storedproc. That said, I can't imagine why you'd get this
particular case if that was the problem. See about turning ANSI NULL off in
the analyzer, and see if you suddenly get the nulls in there too.
I'd also like to point out that the performance guide says anything with a
NOT is slower.