Viewing 8 posts - 1 through 8 (of 8 total)
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...
July 8, 2004 at 3:13 pm
DELETE FROM MyTable WHERE MyDateTimeField <= DATEADD(dd, -60, GETDATE())
July 8, 2004 at 2:54 pm
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...
June 17, 2004 at 3:44 pm
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...
June 17, 2004 at 3:42 pm
You could create a cursor for the #temp table and delete rows one by one with the syntax WHERE CURRENT OF.
June 17, 2004 at 3:26 pm
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,...
June 17, 2004 at 12:53 pm
CREATE TABLE #PossibleWorkMinutes
(
Client_Rep VARCHAR(50),
Begin_Work DATETIME,
End_Work DATETIME,
TotalWorkDayMinutes INT
 
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
 
INSERT INTO #WorkDoneMinutes
SELECT Client_Rep,
SUM(DATEDIFF(mi, Begin_Work, End_Work))
FROM MyTable
GROUP...
June 16, 2004 at 3:12 am
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
June 16, 2004 at 1:59 am
Viewing 8 posts - 1 through 8 (of 8 total)