Viewing 15 posts - 916 through 930 (of 1,491 total)
Bob is suggesting something like:
INSERT INTO phpbb_posts(forum_id, topic_id, post_subject, post_text)
SELECT F2.forum_id, T.topic_id, R.[subject], R.body
FROM replies R
JOIN phpbb_forums F1
ON R.category = F1.Forum_name
AND forum_type = 0
JOIN phpbb_forums F2
ON F1.forum_id = F2.parent_id
AND R.subcategory...
October 12, 2009 at 3:53 am
With the limited information provided, the best I could suggest for SQL200 would be:
SELECT *
INTO #Inserted
FROM inserted
WHERE fieldname = 'Test'
IF @@ROWCOUNT > 0
BEGIN
-- Use #Inserted instead of inserted
END
If you post...
October 9, 2009 at 10:55 am
It may be worth using a number/tally table:
SELECT TutorID
,ClassDate
,COUNT(DISTINCT N.Number)/60.0 AS TotalTuition
FROM
(
SELECT TutorID
,StartTime
,EndTime
,DATEADD(d, DATEDIFF(d, 0, StartTime), 0) AS ClassDate
FROM #Classes
) D
JOIN dbo.spt_values N
ON N.Number >= DATEDIFF(minute, ClassDate, D.StartTime)
AND N.Number <...
October 7, 2009 at 6:50 am
Or use a calculated column:
ALTER TABLE new_call
ADD CalcStatus AS
CASE
WHEN DATEDIFF(d, [Date Quoted], CURRENT_TIMESTAMP) <= 30
THEN CAST('In Progress' AS varchar(11))
ELSE CAST('Expired' AS varchar(11))
END
October 6, 2009 at 8:46 am
Either:
DELETE T
FROM TempTable T
WHERE NOT EXISTS
(
SELECT T1.ContentID
FROM TempTable T1
WHERE T.ContentId = T1.ContentId
GROUP BY T1.ContentID
HAVING T.Rank = MAX(T1.Rank)
)
or
DELETE T
FROM TempTable T
LEFT JOIN
(
SELECT T1.ContentId, MAX(T1.Rank) AS Rank
FROM TempTable T1
GROUP BY T1.ContentId
) D
ON...
October 2, 2009 at 9:56 am
The idea is to get rid of duplicates and then add in unique negative numbers:
-- get rid of duplicates
UPDATE D
SET ARS_No = 11111
FROM
(
...
October 1, 2009 at 8:43 am
As an unique constraint cannot be created with the NOCHECK option, I would be inclined to put some junk data into the ARS_No column of tbl_Person. Assuming that Person_Id is...
October 1, 2009 at 8:26 am
Your main problem is the complicated table valued function and the cursor does not help.
Try to make the proc set based. As you have not provided DDL or test data...
September 30, 2009 at 10:53 am
From:
http://www.sqlservercentral.com/Forums/Topic758095-338-1.aspx
DECLARE @t TABLE
(
EmpId int NOT NULL
,[Date] smalldatetime NOT NULL
,[Status] varchar(20) NOT NULL
)
INSERT INTO @t
SELECT 1, '20090101', 'Present'
UNION ALL SELECT 1, '20090102', 'Present'
UNION ALL SELECT 1, '20090103', 'Absent'
UNION ALL SELECT 1,...
September 30, 2009 at 8:13 am
I suspect using CASE would work better:
DECLARE @StartDate datetime
,@EndDate datetime
SELECT @StartDate = '20090920'
,@EndDate = '20090923'
SELECT [Terminal ID]
,COUNT([Terminal ID]) AS TotalTrans
,COUNT(CASE WHEN Reject = '' AND [Fee Amount] <> '0000000' AND...
September 29, 2009 at 3:49 am
In SQL2008 this blog from Hugo Kornelis suggests that using MERGE is the way to go:
http://sqlblog.com/blogs/hugo_kornelis/archive/2008/03/10/lets-deprecate-update-from.aspx
If you have a lot of columns to compare then you can use INTERSECT as...
September 15, 2009 at 9:48 am
EXEC sp_executesql ...
Syntax is in BOL.
September 9, 2009 at 4:24 am
Brian Cromwell (9/3/2009)
September 3, 2009 at 11:15 am
Just use the REPLACE command as suggested above. Something like:
SELECT REPLACE(REPLACE(REPLACE(REPLACE(@SearchText, ' and ', '_AND_'), ' or ', '_OR_'), ' ', ' OR '), '_', ' ')
September 2, 2009 at 6:13 am
Calling a SP from within a trigger is usually a bad idea. It also suggests that you are using a cursor within the trigger - an even worse idea.
I suspect...
September 1, 2009 at 11:17 am
Viewing 15 posts - 916 through 930 (of 1,491 total)