![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I want to write a query that finds out whether records from a date exist in a table. At the moment I am using SELECT [Processing Date] FROM [Data] WHERE [Processing Date] = @ContextDate It works but I was hoping there was a quicker query that would stop as soon as the first ocurrence of Contextdate was found |
#3
| |||
| |||
|
|
I want to write a query that finds out whether records from a date exist in a table. At the moment I am using SELECT [Processing Date] FROM [Data] WHERE [Processing Date] = @ContextDate |
|
It works but I was hoping there was a quicker query that would stop as soon as the first ocurrence of Contextdate was found |
#4
| |||
| |||
|
|
I want to write a query that finds out whether records from a date exist in a table. At the moment I am using SELECT [Processing Date] FROM [Data] WHERE [Processing Date] = @ContextDate It works but I was hoping there was a quicker query that would stop as soon as the first ocurrence of Contextdate was found |
#5
| |||
| |||
|
|
On Thursday, July 12, 2012 11:14:51 AM UTC+2, colmkav wrote: I want to write a query that finds out whether records from a date exist in a table. At the moment I am using SELECT [Processing Date] FROM [Data] WHERE [Processing Date] = @ContextDate It works but I was hoping there was a quicker query that would stop as soon as the first ocurrence of Contextdate was found On the exists query what is the actual SQL that should be used? I tried select [Processing Date] FROM data where exists (select * from data WHERE [Processing Date] = @ContextDate) ; But this is actually slower (and also other dates. |
#6
| |||
| |||
|
|
Anyways. use EXISTS when you wish to filter the results from a table based on values in a different table without using a JOIN. That should say: |
#7
| |||
| |||
|
|
I want to write a query that finds out whether records from a date exist in a table. At the moment I am using SELECT [Processing Date] FROM [Data] WHERE [Processing Date] = @ContextDate It works but I was hoping there was a quicker query that would stop as soon as the first ocurrence of Contextdate was found |
![]() |
| Thread Tools | |
| Display Modes | |
| |