Viewing 15 posts - 1,996 through 2,010 (of 3,544 total)
Depends if the table has indexes
If not then either will use a Table Scan
If the column is indexed SUBSTRING will use Index Scan and LIKE will use Index Seek
If the...
Far away is close at hand in the images of elsewhere.
Anon.
January 24, 2006 at 6:02 am
SELECT TOP 5 c_id
FROM (SELECT DISTINCT o_date, c_id FROM @table) a
ORDER BY o_date DESC, c_id ASC
Far away is close at hand in the images of elsewhere.
Anon.
January 23, 2006 at 2:22 am
| Are you worried about readability or performance? |
Both
It depends on...
Far away is close at hand in the images of elsewhere.
Anon.
January 20, 2006 at 7:59 am
Yep but 'I did it my way' to avoid the third PATINDEX ![]()
Far away is close at hand in the images of elsewhere.
Anon.
January 20, 2006 at 7:36 am
Is it top 5 per date?
if so then
SELECT a.o_date, a.c_id
FROM (SELECT o_date, c_id FROM GROUP BY o_date, c_id) a
WHERE a.c_id IN
(SELECT TOP 5 b.c_id
FROM ...
Far away is close at hand in the images of elsewhere.
Anon.
January 20, 2006 at 7:10 am
or
STUFF(STUFF([string],PATINDEX('%[0-9]PT%',[string])+1,255,''),1,PATINDEX('% [.0-9]%PT%',[string]),'')
Far away is close at hand in the images of elsewhere.
Anon.
January 20, 2006 at 6:53 am
![]()
Agree not enough info and too many ambiguities.
My guess would be
DECLARE @date datetime
SELECT @date = MAX([date])
FROM
WHERE [date] < @currentdate...
Far away is close at hand in the images of elsewhere.
Anon.
January 20, 2006 at 3:29 am
| David is great in guessing what people want.... |
Thanks Jesper, I owe it to my Ouija board Far away is close at hand in the images of elsewhere.
Anon.
January 20, 2006 at 2:34 am
Not me personally ![]()
but if you search this forum there will be plenty of advice
two threads to get you going
http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=8&messageid=5834
http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=8&messageid=17678
Far away is close at hand in the images of elsewhere.
Anon.
January 19, 2006 at 8:15 am
DECLARE @max-2 int, @id int, @sql nvarchar(1000)
CREATE TABLE #temp1([ID] int IDENTITY(1,1), COLUMN_NAME sysname)
INSERT INTO #temp1(COLUMN_NAME) SELECT COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'TEST' AND COLUMN_NAME LIKE 'Ext%'
SET...
Far away is close at hand in the images of elsewhere.
Anon.
January 19, 2006 at 6:44 am
How about this then ![]()
SELECT MIN(CODE) AS
FROM (SELECT TOP 3 CODE
FROM
WHERE ENDDATE < @datein
ORDER BY CODE DESC) x...
Far away is close at hand in the images of elsewhere.
Anon.
January 18, 2006 at 7:53 am
How about
SELECT b.CODE
FROM a
INNER JOIN b ON b.[ID] = a.[ID]-3
WHERE @datein BETWEEN a.STARTDATE AND a.ENDDATE
or have I got this completely wrong ![]()
Far away is close at hand in the images of elsewhere.
Anon.
January 18, 2006 at 6:58 am
Not sure what you mean by match prob. Can you post ddl and sample data plus expected output?
I would write your query like this
select ssg.Name + ' ' + supt.Name ...
Far away is close at hand in the images of elsewhere.
Anon.
January 17, 2006 at 7:13 am
DECLARE @months int
SET @months = (YEAR(GETDATE()) * 12) + MONTH(GETDATE())
SELECT [Year],[Month],SUM(ViewCount) AS Downloads
FROM FileViews
WHERE ([Year] * 12) + [Month] BETWEEN @months-2 AND @months
GROUP BY [Year],...
Far away is close at hand in the images of elsewhere.
Anon.
January 17, 2006 at 6:52 am
Depending on what your 'Upload data from txt file to the table' process is you caould put the file exists test, truncate and load all in one step.
Or check the...
Far away is close at hand in the images of elsewhere.
Anon.
January 17, 2006 at 2:23 am
Viewing 15 posts - 1,996 through 2,010 (of 3,544 total)