Forum Replies Created

Viewing 15 posts - 1,996 through 2,010 (of 3,544 total)

  • RE: substring or like

    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.

  • RE: DISTINCT creating problem in query

    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.

  • RE: String Parse

    quoteAre you worried about readability or performance?

    Both It depends on...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: String Parse

    Yep but 'I did it my way' to avoid the third PATINDEX

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: DISTINCT creating problem in query

    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.

  • RE: String Parse

    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.

  • RE: Help Needed

    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.

  • RE: T-SQL HELP

    quoteDavid 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.

  • RE: T-SQL HELP

    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.

  • RE: T-SQL HELP

    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.

  • RE: Date three months ago (sort of...)

    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.

  • RE: Date three months ago (sort of...)

    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.

  • RE: Null Match Prob

    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.

  • RE: The Last Three Months (Year and Month Only)

    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.

  • RE: Checking for File Existence in SQL Server

    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.

Viewing 15 posts - 1,996 through 2,010 (of 3,544 total)