Viewing 15 posts - 1,216 through 1,230 (of 1,496 total)
Derived tables can be regarded as inline views so you cannot pass parameters. Something like the following should work:
SELECT T.col1, T.colDate, T.col3
FROM Table2 T
JOIN (
SELECT T2.col1, MAX(T2.colDate) AS maxDate
FROM Table1...
April 18, 2007 at 8:02 am
The quick method of doing this from the command prompt is:
echo.>>YourFile.csv
You could put this in a batch file.
April 17, 2007 at 8:03 am
Maybe:
SELECT MIN(ProductCode)
FROM YourTable
WHERE ProductCode >= '12'
April 17, 2007 at 7:32 am
If you need dynamic SQL, you can insert the results into a temp table. eg:
CREATE TABLE #Multi
(
Attribute varchar(100) NOT NULL
)
INSERT INTO #Multi
EXEC ('SELECT attribute FROM dbo.Staging WHERE CHARINDEX('','', attribute) >...
April 13, 2007 at 11:03 am
A table variable cannot be used as a parameter. (Also, it seems to be defined as @tMulti not @Multi.)
I see no point with dynamic SQL here. Why not just:
DECLARE @Multi...
April 13, 2007 at 10:37 am
Peter,
Sorry for not being clear.
I was refering to Gary's charindex > 0 test.
April 13, 2007 at 10:27 am
You may need to make sure that parentID <> ChildID in the reference table.
If you have loops in the data I would suggest you get rid of them using iteration.
April 13, 2007 at 9:58 am
SELECT
CAST(LEFT(DataRow, CHARINDEX('A', DataRow) - 1) AS int) AS QuestionNo
,CAST(SUBSTRING(DataRow, CHARINDEX('A', DataRow) + 1, 8000) AS bigint) AS AnswerNo
FROM (
SELECT '02245A555115555155'
) AS YourTable (DataRow)
April 13, 2007 at 9:52 am
Your basic problem is that you need to carry the current parent value through the recursion.
Also, you would probably find it easier if the Reference table was structured better by containing...
April 13, 2007 at 9:00 am
April 13, 2007 at 4:40 am
-- Option 1
-- Dynamic SQL
DECLARE @SQLString nvarchar(4000)
,@Count int
SET @SQLString = N'SELECT @pCount = COUNT(whatever) FROM ' + @ActiveTable
EXEC sp_executesql @SQLString, N'@pCount int OUTPUT', @Count OUTPUT
SELECT @Count
-- Option 2
-- If the...
April 12, 2007 at 11:07 am
or:
UPDATE Membership
SET kMembStatusCode = 2
,StatusDate = GETDATE()
WHERE EXISTS (
SELECT *
FROM OrgsToAppend A
WHERE Membership.OrganisationID = A.OrganisationID
AND A.Member = 1
)
AND kOtherClassDescID = @IDTo
AND MembStatusCode = @Term
April 12, 2007 at 9:37 am
Try:
UPDATE B
SET kMembStatusCode = 2
,StatusDate = GETDATE()
FROM Membership B
JOIN OrgsToAppend A
ON B.OrganisationID = A.OrganisationID
WHERE A.Member = 1
AND B.kOtherClassDescID = @IDTo
AND B.MembStatusCode = @Term
April 12, 2007 at 9:33 am
Maybe:
SELECT T1.*
FROM YourTable T1
JOIN (
SELECT T2.TagName, MAX(T2.[Date]) AS [Date]
FROM YourTable T2
GROUP BY T2.TagName
) D ON T1.TagName = D.TagName
AND T1.[Date] = D.[Date]
ORDER BY T1.[Date] -- DESC
April 12, 2007 at 8:11 am
Viewing 15 posts - 1,216 through 1,230 (of 1,496 total)