Forum Replies Created

Viewing 8 posts - 1 through 8 (of 8 total)

  • RE: CheckSum routine

    I have a function that does it all for you. Inparameters are data and boolean wether or not checkdigit is included.

    Return value is either checkdigit or true/false if checkdigit was...

  • RE: Delete from Where - Older than 60 days...

    DELETE FROM MyTable WHERE MyDateTimeField <= DATEADD(dd, -60, GETDATE())

  • RE: Query to find missing IDs

    Or the more elegant solution:

    SELECT dbo.Customers.ID + 1 AS CustomerID, (SELECT MIN(Custs.ID) FROM dbo.Customers Custs WHERE Custs.ID > dbo.Customers.ID) - dbo.Customers.ID - 1 AS Items

    FROM dbo.Customers

    WHERE (SELECT MIN(Custs.ID) FROM...

  • RE: Query to find missing IDs

    A very fast approach is using following:

    SELECT dbo.Customers.ID + 1 AS CustomerID

    FROM dbo.Customers

    WHERE (SELECT MIN(Custs.ID) FROM dbo.Customers Custs WHERE Custs.ID > dbo.Customers.ID) - dbo.Customers.ID > 1

    UNION

    SELECT dbo.Customers.ID - 1...

  • RE: Old problem - delete duplicates in table

    You could create a cursor for the #temp table and delete rows one by one with the syntax WHERE CURRENT OF.

  • RE: Old problem - delete duplicates in table

    The easy way to do it is to add a new field to the table, call MyID as an IDENTITY (1,1) INT

    And now comes the tricky part...

    ex: select col1, col2, col3,...

  • RE: need help with query

    CREATE TABLE #PossibleWorkMinutes

      (

       Client_Rep VARCHAR(50),

       Begin_Work DATETIME,

       End_Work DATETIME,

       TotalWorkDayMinutes INT

     &nbsp

    INSERT INTO #PossibleWorkMinutes

    SELECT  Client_Rep,

      MIN(Begin_Work),

      MAX(End_Work),

      NULL

    FROM  MyTable

    GROUP BY Client_Rep

    UPDATE  #PossibleWorkMinutes

    SET  TotalWorkDayMinutes = DATEDIFF(mi, Begin_Work, End_Work)

    CREATE TABLE #WorkDoneMinutes

      (

       Client_Rep VARCHAR(50),

       WorkDoneMinutes INT

     &nbsp

    INSERT INTO #WorkDoneMinutes

    SELECT  Client_Rep,

      SUM(DATEDIFF(mi, Begin_Work, End_Work))

    FROM  MyTable

    GROUP...

  • RE: renumbering lines

    CREATE TABLE #Temp

    (

    NewRowID INT IDENTITY (1, 1) NOT NULL,

       OldRowID INT

    )

    INSERT INTO #Temp (OldRowID)

    SELECT MyTable.Col1 FROM MyTable ORDER BY MyTable.Col1

    UPDATE MyTable

    SET MyTable.Col1 = #Temp.NewRowID

    FROM MyTable, #Temp

    WHERE MyTable.Col1 = #Temp.OldRowID

    DROP TABLE #Temp

Viewing 8 posts - 1 through 8 (of 8 total)