I can use MAX to find the largest value but Is there a way or function to find 3 largest value from a column?Originally posted by QaAP
I can use MAX to find the largest value but Is there a way or function to find 3 largest value from a column?
There are various ways. One is:
SELECT col FROM tab
WHERE 3 >
(SELECT COUNT(DISTINCT col) FROM tab tab2
WHERE tab2.col > tab.col);|||Originally posted by andrewst
There are various ways. One is:
SELECT col FROM tab
WHERE 3 >
(SELECT COUNT(DISTINCT col) FROM tab tab2
WHERE tab2.col > tab.col);
I need to get 3 largest values from 1 table and 1 column. eg.
Table1:
Name Age
abc 3
DAJ 8
YYY 19
TTT 25
3 largest column
Name AGE
----
DAJ 8
YYY 19
TTT 25|||OK, so just change the columns in my previous answer:
SELECT name, age
FROM table1
WHERE 3 >
( SELECT COUNT(DISTINCT age)
FROM table1 t1
WHERE t1.age > table1.age
);|||dear friend,
The printing 3rd largest number not working in MySQL5.
************************************************** ******************************
select * from fun;
+---+
| money |
+---+
| 123 |
| 111 |
| 12 |
| 134 |
| 777 |
| 888 |
| 666 |
| 555 |
| 99999 |
| 256 |
| 777 |
+---+
11 rows in set (0.00 sec)
************************************************** **********************************************
select f1.money from fun as f1 where 3>(select count(distinct f1.money) from fun as f1, fun as f2 where f1.money>f2.money order by f1.money desc);
Result is : Empty set (0.01 sec)
Please reply what is the solutin|||I want to print the 3rd largest number of a column say money from table fun as given.
printing 3rd largest number not working
Pls help
The printing 3rd largest number not working in MySQL5.
************************************************** ******************************
select * from fun;
+---+
| money |
+---+
| 123 |
| 111 |
| 12 |
| 134 |
| 777 |
| 888 |
| 666 |
| 555 |
| 99999 |
| 256 |
| 777 |
+---+
11 rows in set (0.00 sec)
************************************************** **********************************************
select f1.money from fun as f1 where 3>(select count(distinct f1.money) from fun as f1, fun as f2 where f1.money>f2.money order by f1.money desc);
Result is : Empty set (0.01 sec)
Please reply what is the solution|||This smells like homework to me, but I'll give you a small hand by relocating your question to the MySQL forum. There is a MySQL-specific extension to SQL specifically to help with tasks like this.
-PatP|||Same as I posted before really:
select f1.money
from fun as f1
where 3 >
( select count(distinct f2.money)
from fun as f2
where f1.money>f2.money
);|||please don't post the same question into more than one forum
threads merged|||hi,
It is giving the result as:
mysql> select f1.money
-> from fun as f1
-> where 3 >
-> ( select count(distinct f2.money)
-> from fun as f2
-> where f1.money>f2.money
-> );
+---+
| money |
+---+
| 123 |
| 111 |
| 12 |
+---+
3 rows in set (0.00 sec)
(i.e.) It is taking first three rows of the column money. But I want to print 3 greatest number. i.e.
99999
888
777|||somehow, the inequality was incorrectly reversed
this works (i tested it on your sample data) --select distinct money
from fun as f1
where 3 >
( select count(distinct money)
from fun
where f1.money < money
)
order by money desc|||Other solution, without subquery but with (self) join:
SELECT A.age, A.whatever
FROM table1 AS A
INNER JOIN table1 AS B
ON A.age <= B.age
GROUP BY A.age, A.whatever -- make sure this is at least a PK of table1
HAVING count(*) <= 3
If you just want to see the third largest, replace "<= 3" by "= 3".
Depending on the size of your table (and presence of indices etc.) the subquery solution or the join solution might be the most performant one.|||Yet another solution, but unfortunately a platform-specific one (just like the mysql one), now for DB2:
SELECT *
FROM table1
ORDER BY age DESC
FETCH FIRST 3 ROWS ONLYB.T.W., this is the most performant solution of the three when using DB2.|||excuse me? which mysql-specific solution would you be referring to? :)
pat did not move the thread, we are still in the generic SQL forum, and all the solutions offered up until your last have been good, standard sql
granted, there is a cleaner mysql solution, but fondofopensource re-opened a three-year-old thread in the SQL forum as well as starting a duplicate post in the mysql forum, so when i merged the threads, i left the merged thread here
let's wait to see if he/she is interested in the mysql solution too...|||Sorry, then.
You are right.
Actually, I didn't pay much attention to the mysql stuff being said ;)|||no harm, no foul ;)
the "standard sql" forum is of special interest to me, and i will routinely move threads out of it into more appropriate forums when necessary
this was a difficult case, because the question was actually posted into the mysql forum as well as here
so my decision to merge the threads and leave them here was based not on the poster's database but on the sql solution offered earlier in this thread (which the poster was trying to implement)
Showing posts with label max. Show all posts
Showing posts with label max. Show all posts
Tuesday, March 20, 2012
Tuesday, March 6, 2012
2005 xml equality
There is not equality comparison for xml data type. You cannot cast xml to
text or ntext, but you can cast to varbinary(max), varchar(max), and
nvarchar(max).
A couple of routes you can take (I'm sure there are other ways as well):
1. Assuming the incoming xml is identical in structure (whitespace doesn't
count) to the existing xml value , you could cast the incoming value and
existing value to varbinary(max) and compare.
2. You could iterate through the xml and compare, although this is more
complicated to implement and slower as the size of the xml value increases.
Peter DeBetta, MVP - SQL Server
http://sqlblog.com
"Marc Gravell" <marc.gravell@.gmail.com> wrote in message
news:e$kf%23YvwHHA.5008@.TK2MSFTNGP05.phx.gbl...
> Is there any (perhaps roundabout) mechanism for testing xml columns
> for equality?
> Specifically, as part of a bulk update (i.e. into a staging table that
> is then migrated) I want to short-circuit any records whose xml hasn't
> actually changed, since I have audit requirements and I don't want to
> fill in the audit every time a record is present in an extract - only
> when it has actually changed.
> Any ideas? I have tried a few approaches like extracting as ntext or
> some of the checksum functions, but not with any success. CLR perhaps?
> Marc
>
>
Thanks Peter - I'll give the varbinary(max)/varchar(max)/nvarchar(max)
route a go in the morning. I'm confident that this will make
everything work - much appreciated.
Marc
text or ntext, but you can cast to varbinary(max), varchar(max), and
nvarchar(max).
A couple of routes you can take (I'm sure there are other ways as well):
1. Assuming the incoming xml is identical in structure (whitespace doesn't
count) to the existing xml value , you could cast the incoming value and
existing value to varbinary(max) and compare.
2. You could iterate through the xml and compare, although this is more
complicated to implement and slower as the size of the xml value increases.
Peter DeBetta, MVP - SQL Server
http://sqlblog.com
"Marc Gravell" <marc.gravell@.gmail.com> wrote in message
news:e$kf%23YvwHHA.5008@.TK2MSFTNGP05.phx.gbl...
> Is there any (perhaps roundabout) mechanism for testing xml columns
> for equality?
> Specifically, as part of a bulk update (i.e. into a staging table that
> is then migrated) I want to short-circuit any records whose xml hasn't
> actually changed, since I have audit requirements and I don't want to
> fill in the audit every time a record is present in an extract - only
> when it has actually changed.
> Any ideas? I have tried a few approaches like extracting as ntext or
> some of the checksum functions, but not with any success. CLR perhaps?
> Marc
>
>
Thanks Peter - I'll give the varbinary(max)/varchar(max)/nvarchar(max)
route a go in the morning. I'm confident that this will make
everything work - much appreciated.
Marc
Sunday, February 19, 2012
2005 Max CPU's
I need some clarification on the maximum number of CPUs that will be used by
SQL Server Standard Edition. The documentation states that 4 CPUs is the
maximum for Standard. If those 4 CPUs are dual core, will SQL Server
utilize all 8 logical CPUs? I read some posts that indicated that only 4
of the 8 logical CPUs will be used by SQL Server Standard Edition. Is this
true?
Thanks!
ChrisChris,
CPUs are physical chips, whether single, dual, or quad core. In a
conversation from a few months ago Jens K. Suessmeyer pointed to the
explanation about SQL Server Express over the same issue:
http://support.microsoft.com/kb/914278/en-us
RLF
"Chris Gallelli" <Chris.Gallelli@.hotmail.com> wrote in message
news:uQ25vsfXIHA.4808@.TK2MSFTNGP05.phx.gbl...
>I need some clarification on the maximum number of CPUs that will be used
>by SQL Server Standard Edition. The documentation states that 4 CPUs is
>the maximum for Standard. If those 4 CPUs are dual core, will SQL Server
>utilize all 8 logical CPUs? I read some posts that indicated that only 4
>of the 8 logical CPUs will be used by SQL Server Standard Edition. Is this
>true?
> Thanks!
> Chris
>|||Russell,
Thanks for the quick response. Your answer gives me some more insight into
the Express edition but I am looking specifically at SQL Server 2005
Standard Edition. If a machine running SQL Server 2005 Standard Edition has
4 Dual Core Processors, will SQL Server use all 8 logical CPUs?
The following link contains a discussion that is asking the same question:
http://www.codeprof.com/dev-archive/120/19-95-1201327.shtm
"Russell Fields" <russellfields@.nomail.com> wrote in message
news:%23UK7czfXIHA.484@.TK2MSFTNGP06.phx.gbl...
> Chris,
> CPUs are physical chips, whether single, dual, or quad core. In a
> conversation from a few months ago Jens K. Suessmeyer pointed to the
> explanation about SQL Server Express over the same issue:
> http://support.microsoft.com/kb/914278/en-us
> RLF
> "Chris Gallelli" <Chris.Gallelli@.hotmail.com> wrote in message
> news:uQ25vsfXIHA.4808@.TK2MSFTNGP05.phx.gbl...
>>I need some clarification on the maximum number of CPUs that will be used
>>by SQL Server Standard Edition. The documentation states that 4 CPUs is
>>the maximum for Standard. If those 4 CPUs are dual core, will SQL Server
>>utilize all 8 logical CPUs? I read some posts that indicated that only 4
>>of the 8 logical CPUs will be used by SQL Server Standard Edition. Is
>>this true?
>> Thanks!
>> Chris
>|||Hi Chris
Yes, SQL 2005 Std Edn definitely uses all 8 CPUs. The restriction is only
for physical CPUs, not logical so it's possible to have 4 Quad Core CPUs
with 16 logical all working under SQL 2005 Std Edn
Regards,
Greg Linwood
SQL Server MVP
http://blogs.sqlserver.org.au/blogs/greg_linwood
Benchmark your query performance
http://www.SQLBenchmarkPro.com
"Chris Gallelli" <Chris.Gallelli@.hotmail.com> wrote in message
news:%23jBFhMgXIHA.4476@.TK2MSFTNGP06.phx.gbl...
> Russell,
> Thanks for the quick response. Your answer gives me some more insight
> into the Express edition but I am looking specifically at SQL Server 2005
> Standard Edition. If a machine running SQL Server 2005 Standard Edition
> has 4 Dual Core Processors, will SQL Server use all 8 logical CPUs?
> The following link contains a discussion that is asking the same question:
> http://www.codeprof.com/dev-archive/120/19-95-1201327.shtm
>
> "Russell Fields" <russellfields@.nomail.com> wrote in message
> news:%23UK7czfXIHA.484@.TK2MSFTNGP06.phx.gbl...
>> Chris,
>> CPUs are physical chips, whether single, dual, or quad core. In a
>> conversation from a few months ago Jens K. Suessmeyer pointed to the
>> explanation about SQL Server Express over the same issue:
>> http://support.microsoft.com/kb/914278/en-us
>> RLF
>> "Chris Gallelli" <Chris.Gallelli@.hotmail.com> wrote in message
>> news:uQ25vsfXIHA.4808@.TK2MSFTNGP05.phx.gbl...
>>I need some clarification on the maximum number of CPUs that will be used
>>by SQL Server Standard Edition. The documentation states that 4 CPUs is
>>the maximum for Standard. If those 4 CPUs are dual core, will SQL Server
>>utilize all 8 logical CPUs? I read some posts that indicated that only
>>4 of the 8 logical CPUs will be used by SQL Server Standard Edition. Is
>>this true?
>> Thanks!
>> Chris
>>
>|||Sorry. (But I thought the analogy carried through just fine.) - RLF
"Chris Gallelli" <Chris.Gallelli@.hotmail.com> wrote in message
news:%23jBFhMgXIHA.4476@.TK2MSFTNGP06.phx.gbl...
> Russell,
> Thanks for the quick response. Your answer gives me some more insight
> into the Express edition but I am looking specifically at SQL Server 2005
> Standard Edition. If a machine running SQL Server 2005 Standard Edition
> has 4 Dual Core Processors, will SQL Server use all 8 logical CPUs?
> The following link contains a discussion that is asking the same question:
> http://www.codeprof.com/dev-archive/120/19-95-1201327.shtm
>
> "Russell Fields" <russellfields@.nomail.com> wrote in message
> news:%23UK7czfXIHA.484@.TK2MSFTNGP06.phx.gbl...
>> Chris,
>> CPUs are physical chips, whether single, dual, or quad core. In a
>> conversation from a few months ago Jens K. Suessmeyer pointed to the
>> explanation about SQL Server Express over the same issue:
>> http://support.microsoft.com/kb/914278/en-us
>> RLF
>> "Chris Gallelli" <Chris.Gallelli@.hotmail.com> wrote in message
>> news:uQ25vsfXIHA.4808@.TK2MSFTNGP05.phx.gbl...
>>I need some clarification on the maximum number of CPUs that will be used
>>by SQL Server Standard Edition. The documentation states that 4 CPUs is
>>the maximum for Standard. If those 4 CPUs are dual core, will SQL Server
>>utilize all 8 logical CPUs? I read some posts that indicated that only
>>4 of the 8 logical CPUs will be used by SQL Server Standard Edition. Is
>>this true?
>> Thanks!
>> Chris
>>
>
SQL Server Standard Edition. The documentation states that 4 CPUs is the
maximum for Standard. If those 4 CPUs are dual core, will SQL Server
utilize all 8 logical CPUs? I read some posts that indicated that only 4
of the 8 logical CPUs will be used by SQL Server Standard Edition. Is this
true?
Thanks!
ChrisChris,
CPUs are physical chips, whether single, dual, or quad core. In a
conversation from a few months ago Jens K. Suessmeyer pointed to the
explanation about SQL Server Express over the same issue:
http://support.microsoft.com/kb/914278/en-us
RLF
"Chris Gallelli" <Chris.Gallelli@.hotmail.com> wrote in message
news:uQ25vsfXIHA.4808@.TK2MSFTNGP05.phx.gbl...
>I need some clarification on the maximum number of CPUs that will be used
>by SQL Server Standard Edition. The documentation states that 4 CPUs is
>the maximum for Standard. If those 4 CPUs are dual core, will SQL Server
>utilize all 8 logical CPUs? I read some posts that indicated that only 4
>of the 8 logical CPUs will be used by SQL Server Standard Edition. Is this
>true?
> Thanks!
> Chris
>|||Russell,
Thanks for the quick response. Your answer gives me some more insight into
the Express edition but I am looking specifically at SQL Server 2005
Standard Edition. If a machine running SQL Server 2005 Standard Edition has
4 Dual Core Processors, will SQL Server use all 8 logical CPUs?
The following link contains a discussion that is asking the same question:
http://www.codeprof.com/dev-archive/120/19-95-1201327.shtm
"Russell Fields" <russellfields@.nomail.com> wrote in message
news:%23UK7czfXIHA.484@.TK2MSFTNGP06.phx.gbl...
> Chris,
> CPUs are physical chips, whether single, dual, or quad core. In a
> conversation from a few months ago Jens K. Suessmeyer pointed to the
> explanation about SQL Server Express over the same issue:
> http://support.microsoft.com/kb/914278/en-us
> RLF
> "Chris Gallelli" <Chris.Gallelli@.hotmail.com> wrote in message
> news:uQ25vsfXIHA.4808@.TK2MSFTNGP05.phx.gbl...
>>I need some clarification on the maximum number of CPUs that will be used
>>by SQL Server Standard Edition. The documentation states that 4 CPUs is
>>the maximum for Standard. If those 4 CPUs are dual core, will SQL Server
>>utilize all 8 logical CPUs? I read some posts that indicated that only 4
>>of the 8 logical CPUs will be used by SQL Server Standard Edition. Is
>>this true?
>> Thanks!
>> Chris
>|||Hi Chris
Yes, SQL 2005 Std Edn definitely uses all 8 CPUs. The restriction is only
for physical CPUs, not logical so it's possible to have 4 Quad Core CPUs
with 16 logical all working under SQL 2005 Std Edn
Regards,
Greg Linwood
SQL Server MVP
http://blogs.sqlserver.org.au/blogs/greg_linwood
Benchmark your query performance
http://www.SQLBenchmarkPro.com
"Chris Gallelli" <Chris.Gallelli@.hotmail.com> wrote in message
news:%23jBFhMgXIHA.4476@.TK2MSFTNGP06.phx.gbl...
> Russell,
> Thanks for the quick response. Your answer gives me some more insight
> into the Express edition but I am looking specifically at SQL Server 2005
> Standard Edition. If a machine running SQL Server 2005 Standard Edition
> has 4 Dual Core Processors, will SQL Server use all 8 logical CPUs?
> The following link contains a discussion that is asking the same question:
> http://www.codeprof.com/dev-archive/120/19-95-1201327.shtm
>
> "Russell Fields" <russellfields@.nomail.com> wrote in message
> news:%23UK7czfXIHA.484@.TK2MSFTNGP06.phx.gbl...
>> Chris,
>> CPUs are physical chips, whether single, dual, or quad core. In a
>> conversation from a few months ago Jens K. Suessmeyer pointed to the
>> explanation about SQL Server Express over the same issue:
>> http://support.microsoft.com/kb/914278/en-us
>> RLF
>> "Chris Gallelli" <Chris.Gallelli@.hotmail.com> wrote in message
>> news:uQ25vsfXIHA.4808@.TK2MSFTNGP05.phx.gbl...
>>I need some clarification on the maximum number of CPUs that will be used
>>by SQL Server Standard Edition. The documentation states that 4 CPUs is
>>the maximum for Standard. If those 4 CPUs are dual core, will SQL Server
>>utilize all 8 logical CPUs? I read some posts that indicated that only
>>4 of the 8 logical CPUs will be used by SQL Server Standard Edition. Is
>>this true?
>> Thanks!
>> Chris
>>
>|||Sorry. (But I thought the analogy carried through just fine.) - RLF
"Chris Gallelli" <Chris.Gallelli@.hotmail.com> wrote in message
news:%23jBFhMgXIHA.4476@.TK2MSFTNGP06.phx.gbl...
> Russell,
> Thanks for the quick response. Your answer gives me some more insight
> into the Express edition but I am looking specifically at SQL Server 2005
> Standard Edition. If a machine running SQL Server 2005 Standard Edition
> has 4 Dual Core Processors, will SQL Server use all 8 logical CPUs?
> The following link contains a discussion that is asking the same question:
> http://www.codeprof.com/dev-archive/120/19-95-1201327.shtm
>
> "Russell Fields" <russellfields@.nomail.com> wrote in message
> news:%23UK7czfXIHA.484@.TK2MSFTNGP06.phx.gbl...
>> Chris,
>> CPUs are physical chips, whether single, dual, or quad core. In a
>> conversation from a few months ago Jens K. Suessmeyer pointed to the
>> explanation about SQL Server Express over the same issue:
>> http://support.microsoft.com/kb/914278/en-us
>> RLF
>> "Chris Gallelli" <Chris.Gallelli@.hotmail.com> wrote in message
>> news:uQ25vsfXIHA.4808@.TK2MSFTNGP05.phx.gbl...
>>I need some clarification on the maximum number of CPUs that will be used
>>by SQL Server Standard Edition. The documentation states that 4 CPUs is
>>the maximum for Standard. If those 4 CPUs are dual core, will SQL Server
>>utilize all 8 logical CPUs? I read some posts that indicated that only
>>4 of the 8 logical CPUs will be used by SQL Server Standard Edition. Is
>>this true?
>> Thanks!
>> Chris
>>
>
Thursday, February 16, 2012
2005 Inconsistent Results with VarBinary fields
Hello,
I seem to be encountering some inconsistent results with full text searching
against a combination of VarChar(max) and VarBinary(max) fields.
I have a table which has both a VarChar(max) field and a VarBinary(max)
field. The table is meant to either have text or an attachement (or both).
I have indexed both fields. When I do a particular search against just the
Varbinary field I get 16 results. When I do the same query, but with both
columns specified, I only get 8 results. Maybe there is a good reason for
this, but it seems like adding more fields to the search should not result
in fewer hits. And I have verified that the records it is missing truly
contain the word I am looking for. Below are the relevant queries.
Any help would be appreciated. Thanks!
Randall
-- ***** Table ****
create table dbo.z_FullTextChild (
FullTextChildID uniqueidentifier ROWGUIDCOL NOT NULL default newid(),
FullTextMainID uniqueidentifier not null,
LongText VarChar(max) null,
AttachmentFileName VarChar(256) null,
AttachmentFileType VarChar(15) null,
Attachment VarBinary(max),
constraint PK_FullTextChild primary key (FullTextChildID),
constraint PK_FullTextChild_FullTextMain foreign key (FullTextMainID)
references dbo.z_FullTextMain(FullTextMainID) on update cascade on delete
cascade
)
go
-- ******** Full Text Index *********
create fulltext index on dbo.z_FullTextChild
(LongText, Attachment TYPE COLUMN AttachmentFileType )
key index PK_FullTextChild
on ftTracker
with CHANGE_TRACKING AUTO
go
-- ******* Query that yields 16 results ***************
select ftc.LongText, ftc.AttachmentFileName, ft.Rank
from z_FullTextChild ftc
join freetexttable (z_FullTextChild, (Attachment), 'INFORMATION', 100) ft
on ft.[KEY]=ftc.FullTextChildID
where
ftc.AttachmentFileName is not null
order by ft.Rank desc
-- ******** Query that yields 8 results (only difference is in selected
columns) ******************
select ftc.LongText, ftc.AttachmentFileName, ft.Rank
from z_FullTextChild ftc
join freetexttable (z_FullTextChild, (Attachment, LongText), 'INFORMATION',
100) ft on ft.[KEY]=ftc.FullTextChildID
where
ftc.AttachmentFileName is not null
order by ft.Rank desc
-- ******* Select @.@.Version ***********
Microsoft SQL Server 2005 - 9.00.1187.07 (Intel X86) May 24 2005 18:22:46
Copyright (c) 1988-2005 Microsoft Corporation Beta Edition on Windows NT
5.1 (Build 2600: Service Pack 2)
I have tried to repro this problem and am unable to do so. Can you perhaps
do this query?
select ftc.LongText, ftc.AttachmentFileName, ft.Rank
from z_FullTextChild ftc
join freetexttable (z_FullTextChild, (LongText), 'INFORMATION',
100) ft on ft.[KEY]=ftc.FullTextChildID
where
ftc.AttachmentFileName is not null
order by ft.Rank desc
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"Randall" <randall@.randall.com> wrote in message
news:uYYBzNuhFHA.2472@.TK2MSFTNGP15.phx.gbl...
> Hello,
> I seem to be encountering some inconsistent results with full text
searching
> against a combination of VarChar(max) and VarBinary(max) fields.
> I have a table which has both a VarChar(max) field and a VarBinary(max)
> field. The table is meant to either have text or an attachement (or
both).
> I have indexed both fields. When I do a particular search against just
the
> Varbinary field I get 16 results. When I do the same query, but with both
> columns specified, I only get 8 results. Maybe there is a good reason for
> this, but it seems like adding more fields to the search should not result
> in fewer hits. And I have verified that the records it is missing truly
> contain the word I am looking for. Below are the relevant queries.
> Any help would be appreciated. Thanks!
> Randall
> -- ***** Table ****
> create table dbo.z_FullTextChild (
> FullTextChildID uniqueidentifier ROWGUIDCOL NOT NULL default newid(),
> FullTextMainID uniqueidentifier not null,
> LongText VarChar(max) null,
> AttachmentFileName VarChar(256) null,
> AttachmentFileType VarChar(15) null,
> Attachment VarBinary(max),
> constraint PK_FullTextChild primary key (FullTextChildID),
> constraint PK_FullTextChild_FullTextMain foreign key (FullTextMainID)
> references dbo.z_FullTextMain(FullTextMainID) on update cascade on delete
> cascade
> )
> go
> -- ******** Full Text Index *********
> create fulltext index on dbo.z_FullTextChild
> (LongText, Attachment TYPE COLUMN AttachmentFileType )
> key index PK_FullTextChild
> on ftTracker
> with CHANGE_TRACKING AUTO
> go
> -- ******* Query that yields 16 results ***************
> select ftc.LongText, ftc.AttachmentFileName, ft.Rank
> from z_FullTextChild ftc
> join freetexttable (z_FullTextChild, (Attachment), 'INFORMATION', 100) ft
> on ft.[KEY]=ftc.FullTextChildID
> where
> ftc.AttachmentFileName is not null
> order by ft.Rank desc
> -- ******** Query that yields 8 results (only difference is in selected
> columns) ******************
> select ftc.LongText, ftc.AttachmentFileName, ft.Rank
> from z_FullTextChild ftc
> join freetexttable (z_FullTextChild, (Attachment, LongText),
'INFORMATION',
> 100) ft on ft.[KEY]=ftc.FullTextChildID
> where
> ftc.AttachmentFileName is not null
> order by ft.Rank desc
> -- ******* Select @.@.Version ***********
> Microsoft SQL Server 2005 - 9.00.1187.07 (Intel X86) May 24 2005
18:22:46
> Copyright (c) 1988-2005 Microsoft Corporation Beta Edition on Windows NT
> 5.1 (Build 2600: Service Pack 2)
>
>
|||Thanks for the reply.
That particular query yields no hits because currently none of the records
that have attachments have any LongText associated with them (although that
could change in the future).
Randall
"Hilary Cotter" <hilary.cotter@.gmail.com> wrote in message
news:O4eEKfuhFHA.1048@.tk2msftngp13.phx.gbl...
>I have tried to repro this problem and am unable to do so. Can you perhaps
> do this query?
> select ftc.LongText, ftc.AttachmentFileName, ft.Rank
> from z_FullTextChild ftc
> join freetexttable (z_FullTextChild, (LongText), 'INFORMATION',
> 100) ft on ft.[KEY]=ftc.FullTextChildID
> where
> ftc.AttachmentFileName is not null
> order by ft.Rank desc
>
> --
> Hilary Cotter
> Looking for a SQL Server replication book?
> http://www.nwsu.com/0974973602.html
> Looking for a FAQ on Indexing Services/SQL FTS
> http://www.indexserverfaq.com
> "Randall" <randall@.randall.com> wrote in message
> news:uYYBzNuhFHA.2472@.TK2MSFTNGP15.phx.gbl...
> searching
> both).
> the
> 'INFORMATION',
> 18:22:46
>
I seem to be encountering some inconsistent results with full text searching
against a combination of VarChar(max) and VarBinary(max) fields.
I have a table which has both a VarChar(max) field and a VarBinary(max)
field. The table is meant to either have text or an attachement (or both).
I have indexed both fields. When I do a particular search against just the
Varbinary field I get 16 results. When I do the same query, but with both
columns specified, I only get 8 results. Maybe there is a good reason for
this, but it seems like adding more fields to the search should not result
in fewer hits. And I have verified that the records it is missing truly
contain the word I am looking for. Below are the relevant queries.
Any help would be appreciated. Thanks!
Randall
-- ***** Table ****
create table dbo.z_FullTextChild (
FullTextChildID uniqueidentifier ROWGUIDCOL NOT NULL default newid(),
FullTextMainID uniqueidentifier not null,
LongText VarChar(max) null,
AttachmentFileName VarChar(256) null,
AttachmentFileType VarChar(15) null,
Attachment VarBinary(max),
constraint PK_FullTextChild primary key (FullTextChildID),
constraint PK_FullTextChild_FullTextMain foreign key (FullTextMainID)
references dbo.z_FullTextMain(FullTextMainID) on update cascade on delete
cascade
)
go
-- ******** Full Text Index *********
create fulltext index on dbo.z_FullTextChild
(LongText, Attachment TYPE COLUMN AttachmentFileType )
key index PK_FullTextChild
on ftTracker
with CHANGE_TRACKING AUTO
go
-- ******* Query that yields 16 results ***************
select ftc.LongText, ftc.AttachmentFileName, ft.Rank
from z_FullTextChild ftc
join freetexttable (z_FullTextChild, (Attachment), 'INFORMATION', 100) ft
on ft.[KEY]=ftc.FullTextChildID
where
ftc.AttachmentFileName is not null
order by ft.Rank desc
-- ******** Query that yields 8 results (only difference is in selected
columns) ******************
select ftc.LongText, ftc.AttachmentFileName, ft.Rank
from z_FullTextChild ftc
join freetexttable (z_FullTextChild, (Attachment, LongText), 'INFORMATION',
100) ft on ft.[KEY]=ftc.FullTextChildID
where
ftc.AttachmentFileName is not null
order by ft.Rank desc
-- ******* Select @.@.Version ***********
Microsoft SQL Server 2005 - 9.00.1187.07 (Intel X86) May 24 2005 18:22:46
Copyright (c) 1988-2005 Microsoft Corporation Beta Edition on Windows NT
5.1 (Build 2600: Service Pack 2)
I have tried to repro this problem and am unable to do so. Can you perhaps
do this query?
select ftc.LongText, ftc.AttachmentFileName, ft.Rank
from z_FullTextChild ftc
join freetexttable (z_FullTextChild, (LongText), 'INFORMATION',
100) ft on ft.[KEY]=ftc.FullTextChildID
where
ftc.AttachmentFileName is not null
order by ft.Rank desc
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"Randall" <randall@.randall.com> wrote in message
news:uYYBzNuhFHA.2472@.TK2MSFTNGP15.phx.gbl...
> Hello,
> I seem to be encountering some inconsistent results with full text
searching
> against a combination of VarChar(max) and VarBinary(max) fields.
> I have a table which has both a VarChar(max) field and a VarBinary(max)
> field. The table is meant to either have text or an attachement (or
both).
> I have indexed both fields. When I do a particular search against just
the
> Varbinary field I get 16 results. When I do the same query, but with both
> columns specified, I only get 8 results. Maybe there is a good reason for
> this, but it seems like adding more fields to the search should not result
> in fewer hits. And I have verified that the records it is missing truly
> contain the word I am looking for. Below are the relevant queries.
> Any help would be appreciated. Thanks!
> Randall
> -- ***** Table ****
> create table dbo.z_FullTextChild (
> FullTextChildID uniqueidentifier ROWGUIDCOL NOT NULL default newid(),
> FullTextMainID uniqueidentifier not null,
> LongText VarChar(max) null,
> AttachmentFileName VarChar(256) null,
> AttachmentFileType VarChar(15) null,
> Attachment VarBinary(max),
> constraint PK_FullTextChild primary key (FullTextChildID),
> constraint PK_FullTextChild_FullTextMain foreign key (FullTextMainID)
> references dbo.z_FullTextMain(FullTextMainID) on update cascade on delete
> cascade
> )
> go
> -- ******** Full Text Index *********
> create fulltext index on dbo.z_FullTextChild
> (LongText, Attachment TYPE COLUMN AttachmentFileType )
> key index PK_FullTextChild
> on ftTracker
> with CHANGE_TRACKING AUTO
> go
> -- ******* Query that yields 16 results ***************
> select ftc.LongText, ftc.AttachmentFileName, ft.Rank
> from z_FullTextChild ftc
> join freetexttable (z_FullTextChild, (Attachment), 'INFORMATION', 100) ft
> on ft.[KEY]=ftc.FullTextChildID
> where
> ftc.AttachmentFileName is not null
> order by ft.Rank desc
> -- ******** Query that yields 8 results (only difference is in selected
> columns) ******************
> select ftc.LongText, ftc.AttachmentFileName, ft.Rank
> from z_FullTextChild ftc
> join freetexttable (z_FullTextChild, (Attachment, LongText),
'INFORMATION',
> 100) ft on ft.[KEY]=ftc.FullTextChildID
> where
> ftc.AttachmentFileName is not null
> order by ft.Rank desc
> -- ******* Select @.@.Version ***********
> Microsoft SQL Server 2005 - 9.00.1187.07 (Intel X86) May 24 2005
18:22:46
> Copyright (c) 1988-2005 Microsoft Corporation Beta Edition on Windows NT
> 5.1 (Build 2600: Service Pack 2)
>
>
|||Thanks for the reply.
That particular query yields no hits because currently none of the records
that have attachments have any LongText associated with them (although that
could change in the future).
Randall
"Hilary Cotter" <hilary.cotter@.gmail.com> wrote in message
news:O4eEKfuhFHA.1048@.tk2msftngp13.phx.gbl...
>I have tried to repro this problem and am unable to do so. Can you perhaps
> do this query?
> select ftc.LongText, ftc.AttachmentFileName, ft.Rank
> from z_FullTextChild ftc
> join freetexttable (z_FullTextChild, (LongText), 'INFORMATION',
> 100) ft on ft.[KEY]=ftc.FullTextChildID
> where
> ftc.AttachmentFileName is not null
> order by ft.Rank desc
>
> --
> Hilary Cotter
> Looking for a SQL Server replication book?
> http://www.nwsu.com/0974973602.html
> Looking for a FAQ on Indexing Services/SQL FTS
> http://www.indexserverfaq.com
> "Randall" <randall@.randall.com> wrote in message
> news:uYYBzNuhFHA.2472@.TK2MSFTNGP15.phx.gbl...
> searching
> both).
> the
> 'INFORMATION',
> 18:22:46
>
Labels:
combination,
database,
encountering,
fields,
inconsistent,
max,
microsoft,
mysql,
oracle,
searchingagainst,
server,
sql,
text,
varbinary,
varchar
Monday, February 13, 2012
2005 Express Edition Capacity
I am looking for an inexpensive (less than $200 in quantity 100 per month)
database that will meet the following requirements:
Max database file size 2 Gb
Max number of records 2 million
Record insertion rate: 10 per second
Queries while inserting: Max time to complete a basic query over the 2
million records: 5 sec
The database must be robust, i.e. no lost data when inserting and querying.
Does it seem that Express Edition of SQL 2005 would meet these requirements,
especially the number of records and timing requirements? The application is
limited to one computer."Rahim" <Rahim@.discussions.microsoft.com> wrote in message
news:5C2C04DA-2CF3-4F85-983A-80F42ABD2CC1@.microsoft.com...
>I am looking for an inexpensive (less than $200 in quantity 100 per month)
> database that will meet the following requirements:
> Max database file size 2 Gb
> Max number of records 2 million
> Record insertion rate: 10 per second
> Queries while inserting: Max time to complete a basic query over the 2
> million records: 5 sec
> The database must be robust, i.e. no lost data when inserting and
> querying.
> Does it seem that Express Edition of SQL 2005 would meet these
> requirements,
> especially the number of records and timing requirements? The application
> is
> limited to one computer.|||SQLExpress will have no problems with those rates give a proper design and
appropriate hardware. 2 million rows is pretty small for a SQL DB these
days and as long as you have a proper index and are not returning enough
rows to force a scan that should no be a problem. It is free but you should
look at the licensing to make sure you fit the requirements.
--
Andrew J. Kelly SQL MVP
"Rahim" <Rahim@.discussions.microsoft.com> wrote in message
news:5C2C04DA-2CF3-4F85-983A-80F42ABD2CC1@.microsoft.com...
>I am looking for an inexpensive (less than $200 in quantity 100 per month)
> database that will meet the following requirements:
> Max database file size 2 Gb
> Max number of records 2 million
> Record insertion rate: 10 per second
> Queries while inserting: Max time to complete a basic query over the 2
> million records: 5 sec
> The database must be robust, i.e. no lost data when inserting and
> querying.
> Does it seem that Express Edition of SQL 2005 would meet these
> requirements,
> especially the number of records and timing requirements? The application
> is
> limited to one computer.|||"Rahim" <Rahim@.discussions.microsoft.com> wrote in message
news:5C2C04DA-2CF3-4F85-983A-80F42ABD2CC1@.microsoft.com...
>I am looking for an inexpensive (less than $200 in quantity 100 per month)
> database that will meet the following requirements:
> Max database file size 2 Gb
> Max number of records 2 million
> Record insertion rate: 10 per second
> Queries while inserting: Max time to complete a basic query over the 2
> million records: 5 sec
> The database must be robust, i.e. no lost data when inserting and
> querying.
> Does it seem that Express Edition of SQL 2005 would meet these
> requirements,
> especially the number of records and timing requirements? The application
> is
> limited to one computer.
The capacities you mentioned aren't a problem. The only question is over the
rate of updates and the time to complete your queries. These will be
determined by your processor, storage and network performance rather than by
the database software.
10 rows per second looks a little bit odd next to your 2 million row metric.
If 10 rows per second is an average then apparently your database only
retains about 55 hours worth of data.
In the case of your query performance, that's obviously entirely dependent
on the nature of the query. You'll have to test it out.
Hope this helps.
--
David Portas
SQL Server MVP
--|||"Andrew J. Kelly" wrote:
> SQLExpress will have no problems with those rates give a proper design and
> appropriate hardware. 2 million rows is pretty small for a SQL DB these
> days and as long as you have a proper index and are not returning enough
> rows to force a scan that should no be a problem. It is free but you should
> look at the licensing to make sure you fit the requirements.
> --
> Andrew J. Kelly SQL MVP
>
> "Rahim" <Rahim@.discussions.microsoft.com> wrote in message
> news:5C2C04DA-2CF3-4F85-983A-80F42ABD2CC1@.microsoft.com...
> >I am looking for an inexpensive (less than $200 in quantity 100 per month)
> > database that will meet the following requirements:
> > Max database file size 2 Gb
> > Max number of records 2 million
> > Record insertion rate: 10 per second
> > Queries while inserting: Max time to complete a basic query over the 2
> > million records: 5 sec
> > The database must be robust, i.e. no lost data when inserting and
> > querying.
> > Does it seem that Express Edition of SQL 2005 would meet these
> > requirements,
> > especially the number of records and timing requirements? The application
> > is
> > limited to one computer.
>
> Thank you very much for your reply.|||"David Portas" wrote:
> "Rahim" <Rahim@.discussions.microsoft.com> wrote in message
> news:5C2C04DA-2CF3-4F85-983A-80F42ABD2CC1@.microsoft.com...
> >I am looking for an inexpensive (less than $200 in quantity 100 per month)
> > database that will meet the following requirements:
> > Max database file size 2 Gb
> > Max number of records 2 million
> > Record insertion rate: 10 per second
> > Queries while inserting: Max time to complete a basic query over the 2
> > million records: 5 sec
> > The database must be robust, i.e. no lost data when inserting and
> > querying.
> > Does it seem that Express Edition of SQL 2005 would meet these
> > requirements,
> > especially the number of records and timing requirements? The application
> > is
> > limited to one computer.
> The capacities you mentioned aren't a problem. The only question is over the
> rate of updates and the time to complete your queries. These will be
> determined by your processor, storage and network performance rather than by
> the database software.
> 10 rows per second looks a little bit odd next to your 2 million row metric.
> If 10 rows per second is an average then apparently your database only
> retains about 55 hours worth of data.
> In the case of your query performance, that's obviously entirely dependent
> on the nature of the query. You'll have to test it out.
> Hope this helps.
> --
> David Portas
> SQL Server MVP
> --
>
> Thank you for your reply.
The Database will serve to temporarily retain detailed production
information until the product is shipped, after which the information is
discarded, or in a future incarnation, archived. Thus the apparent 55 hour
capacity.
database that will meet the following requirements:
Max database file size 2 Gb
Max number of records 2 million
Record insertion rate: 10 per second
Queries while inserting: Max time to complete a basic query over the 2
million records: 5 sec
The database must be robust, i.e. no lost data when inserting and querying.
Does it seem that Express Edition of SQL 2005 would meet these requirements,
especially the number of records and timing requirements? The application is
limited to one computer."Rahim" <Rahim@.discussions.microsoft.com> wrote in message
news:5C2C04DA-2CF3-4F85-983A-80F42ABD2CC1@.microsoft.com...
>I am looking for an inexpensive (less than $200 in quantity 100 per month)
> database that will meet the following requirements:
> Max database file size 2 Gb
> Max number of records 2 million
> Record insertion rate: 10 per second
> Queries while inserting: Max time to complete a basic query over the 2
> million records: 5 sec
> The database must be robust, i.e. no lost data when inserting and
> querying.
> Does it seem that Express Edition of SQL 2005 would meet these
> requirements,
> especially the number of records and timing requirements? The application
> is
> limited to one computer.|||SQLExpress will have no problems with those rates give a proper design and
appropriate hardware. 2 million rows is pretty small for a SQL DB these
days and as long as you have a proper index and are not returning enough
rows to force a scan that should no be a problem. It is free but you should
look at the licensing to make sure you fit the requirements.
--
Andrew J. Kelly SQL MVP
"Rahim" <Rahim@.discussions.microsoft.com> wrote in message
news:5C2C04DA-2CF3-4F85-983A-80F42ABD2CC1@.microsoft.com...
>I am looking for an inexpensive (less than $200 in quantity 100 per month)
> database that will meet the following requirements:
> Max database file size 2 Gb
> Max number of records 2 million
> Record insertion rate: 10 per second
> Queries while inserting: Max time to complete a basic query over the 2
> million records: 5 sec
> The database must be robust, i.e. no lost data when inserting and
> querying.
> Does it seem that Express Edition of SQL 2005 would meet these
> requirements,
> especially the number of records and timing requirements? The application
> is
> limited to one computer.|||"Rahim" <Rahim@.discussions.microsoft.com> wrote in message
news:5C2C04DA-2CF3-4F85-983A-80F42ABD2CC1@.microsoft.com...
>I am looking for an inexpensive (less than $200 in quantity 100 per month)
> database that will meet the following requirements:
> Max database file size 2 Gb
> Max number of records 2 million
> Record insertion rate: 10 per second
> Queries while inserting: Max time to complete a basic query over the 2
> million records: 5 sec
> The database must be robust, i.e. no lost data when inserting and
> querying.
> Does it seem that Express Edition of SQL 2005 would meet these
> requirements,
> especially the number of records and timing requirements? The application
> is
> limited to one computer.
The capacities you mentioned aren't a problem. The only question is over the
rate of updates and the time to complete your queries. These will be
determined by your processor, storage and network performance rather than by
the database software.
10 rows per second looks a little bit odd next to your 2 million row metric.
If 10 rows per second is an average then apparently your database only
retains about 55 hours worth of data.
In the case of your query performance, that's obviously entirely dependent
on the nature of the query. You'll have to test it out.
Hope this helps.
--
David Portas
SQL Server MVP
--|||"Andrew J. Kelly" wrote:
> SQLExpress will have no problems with those rates give a proper design and
> appropriate hardware. 2 million rows is pretty small for a SQL DB these
> days and as long as you have a proper index and are not returning enough
> rows to force a scan that should no be a problem. It is free but you should
> look at the licensing to make sure you fit the requirements.
> --
> Andrew J. Kelly SQL MVP
>
> "Rahim" <Rahim@.discussions.microsoft.com> wrote in message
> news:5C2C04DA-2CF3-4F85-983A-80F42ABD2CC1@.microsoft.com...
> >I am looking for an inexpensive (less than $200 in quantity 100 per month)
> > database that will meet the following requirements:
> > Max database file size 2 Gb
> > Max number of records 2 million
> > Record insertion rate: 10 per second
> > Queries while inserting: Max time to complete a basic query over the 2
> > million records: 5 sec
> > The database must be robust, i.e. no lost data when inserting and
> > querying.
> > Does it seem that Express Edition of SQL 2005 would meet these
> > requirements,
> > especially the number of records and timing requirements? The application
> > is
> > limited to one computer.
>
> Thank you very much for your reply.|||"David Portas" wrote:
> "Rahim" <Rahim@.discussions.microsoft.com> wrote in message
> news:5C2C04DA-2CF3-4F85-983A-80F42ABD2CC1@.microsoft.com...
> >I am looking for an inexpensive (less than $200 in quantity 100 per month)
> > database that will meet the following requirements:
> > Max database file size 2 Gb
> > Max number of records 2 million
> > Record insertion rate: 10 per second
> > Queries while inserting: Max time to complete a basic query over the 2
> > million records: 5 sec
> > The database must be robust, i.e. no lost data when inserting and
> > querying.
> > Does it seem that Express Edition of SQL 2005 would meet these
> > requirements,
> > especially the number of records and timing requirements? The application
> > is
> > limited to one computer.
> The capacities you mentioned aren't a problem. The only question is over the
> rate of updates and the time to complete your queries. These will be
> determined by your processor, storage and network performance rather than by
> the database software.
> 10 rows per second looks a little bit odd next to your 2 million row metric.
> If 10 rows per second is an average then apparently your database only
> retains about 55 hours worth of data.
> In the case of your query performance, that's obviously entirely dependent
> on the nature of the query. You'll have to test it out.
> Hope this helps.
> --
> David Portas
> SQL Server MVP
> --
>
> Thank you for your reply.
The Database will serve to temporarily retain detailed production
information until the product is shipped, after which the information is
discarded, or in a future incarnation, archived. Thus the apparent 55 hour
capacity.
Subscribe to:
Posts (Atom)