Forum Replies Created

Viewing 15 posts - 1,711 through 1,725 (of 3,543 total)

  • RE: Table Column as Variable

    quote...for that value to be stored in a variable...

    Use sp_executesql like this

    DECLARE @result varchar(255)

    SET @sql =...

  • RE: Subtracting 1 from a date value

    quoteBut you also need to look up the ISO-8601 format for temproal data so you will not use...
  • RE: select reoccuring values only

    Then add a GROUP BY and HAVING like

    SELECT loi.LOB_ID, loi.EUS_ID, loi.LOI_START_DATE, loi.LOI_END_DATE, eu.CTY_CODE

    FROM @learning_object_instances loi

    JOIN @end_users eu ON eu.EUS_ID = loi.EUS_ID

    WHERE eu.CTY_CODE = 'RU' and loi.LOI_START_DATE...

  • RE: Subtracting 1 from a date value

    DATEADD(day, -1, '31/10/2006')

  • RE: select reoccuring values only

    Agree, requirements are unclear

    As far as I can determine

    SELECT i.LOB_ID, i.EUS_ID, i.LOI_START_DATE, i.LOI_END_DATE, u.CTY_CODE

    FROM learning_object_instances i

    CROSS JOIN end_users u

    WHERE u.CTY_CODE = 'RU' AND i.LOI_START_DATE > 'September 7, 2006'

    GROUP...

  • RE: splitting a string

    Not withstanding Jeff's comments

    if all the names are the same format

    PARSENAME(REPLACE(REPLACE(full_name,',',''),' ','.'),2) AS [First_Name],

    PARSENAME(REPLACE(REPLACE(full_name,',',''),' ','.'),1) AS [Middle_Name],

    PARSENAME(REPLACE(REPLACE(full_name,',',''),' ','.'),3) AS [Last_Name]

     

  • RE: Count Decimal Places

    10-PATINDEX('%[^0]%',REVERSE(RIGHT(CAST(mynumber as varchar),9))+'1')

    1,000,000 rows <=10 secs

     

  • RE: Calculating time between 2 dates minus time from week(s) end(s)

    This type of problem has occurred in a number of threads on this site with various answers, one of which is to do calculus on the days of the week by...

  • RE: Calculating time between 2 dates minus time from week(s) end(s)

    DATEDIFF(hour, date1, date2) - (DATEDIFF(week, date1, date2) * 48)

    providing date1 and date2 are not sat/sun dates

     

  • RE: Levels & do / for loop in MSSQL procedure..

    Don't know what coding that is but my guess for a solution would be

    CREATE PROCEDURE TopCustomerValue2

      @TopCompany CHAR(36) OUTPUT,

      TopValue INT OUTPUT)

    AS

    SELECT TOP 1 @TopCompany =...

  • RE: UDF inconsistent returns

    In that case go back to my original solution and expand it

    DECLARE @index int

    SET @String = REPLACE(@String,' ','')

    SET @index = PATINDEX('%Period:[0-9][0-9/][0-9/]%',@String)

    SET @String = STUFF(@String,1,@index + 6,'')

    SET...

  • RE: UDF inconsistent returns

    OK then

    SELECT

    CAST(LEFT(STUFF([String],1,PATINDEX('%Period: [0-9/ ][0-9/ ][0-9/ ]%',[String])+7,''),PATINDEX('%[^0-9/ ]%',STUFF([String],1,PATINDEX('%Period: [0-9/ ][0-9/ ][0-9/ ]%',[String])+7,''))-1) as datetime) AS [FirstDate],

    CAST(LEFT(SUBSTRING([String],PATINDEX('%Period: [0-9/ ][0-9/ ][0-9/ ]%',[String])+7+PATINDEX('%[^0-9/ ]%',STUFF([String],1,PATINDEX('%Period: [0-9/ ][0-9/ ][0-9/ ]%',[String])+7,''))+2,255),PATINDEX('%[^0-9/ ]%',SUBSTRING([String],PATINDEX('%Period: [0-9/ ][0-9/ ][0-9/...

  • RE: UDF inconsistent returns

    I agree with Vladan that it  is over complicated

    I believe this would achieve the same

    SET DATEFORMAT DMY

    SET @String = REPLACE(@String,' ','')

    SET @String = SUBSTRING(@String,PATINDEX('%to[0-9][0-9/][0-9/]%',@String)+2,255)

    SET @String = LEFT(@String,PATINDEX('%[^0-9/]%',@String)-1)...

  • RE: Grouping issue

    quote...don't have the budget to create a data warehouse...

    Know that as well, but if you could ever get...

  • RE: Grouping issue

    Some table defs, sample data and actual required results would be helpful

    But I consulted my Oiuja board  and.....

    SELECT [Category],[ProductName],[CompanyName]

    FROM

    (SELECT 1 AS [Category],p.[ProductName],p.[CompanyID]

    FROM [Product] p...

Viewing 15 posts - 1,711 through 1,725 (of 3,543 total)