hi all, can someone please explain to me why this isn't working?
I have a store procedure that select a text from the the latest entry...
CREATE PROCEDURE dbo.GetLatest
AS
SELECT
[Text]
FROM MyTable
WHERE
[ID] = (select max(ID) from MyTable)
GO
The above stored procedure worked has needed, but now I need to add another condition from another column... which has three possible values (NULL, 1, -1) ... I want (1).
So I tried doing something like this...
CREATE PROCEDURE dbo.GetLatest
AS
SELECT
[Text]
FROM MyTable
WHERE
[ID] = (select max(ID) from MyTable)
AND
[OtherColumn] = (1)
GO
And passing the value as a parameter...
CREATE PROCEDURE dbo.GetLatest
@OtherColumn int
AS
SELECT
[Text]
FROM MyTable
WHERE
[ID] = (select max(ID) from MyTable)
AND
[OtherColumn] = @OtherColumn
GO
AHHHHHH, AHHHHHH
-a8le
I have a store procedure that select a text from the the latest entry...
CREATE PROCEDURE dbo.GetLatest
AS
SELECT
[Text]
FROM MyTable
WHERE
[ID] = (select max(ID) from MyTable)
GO
The above stored procedure worked has needed, but now I need to add another condition from another column... which has three possible values (NULL, 1, -1) ... I want (1).
So I tried doing something like this...
CREATE PROCEDURE dbo.GetLatest
AS
SELECT
[Text]
FROM MyTable
WHERE
[ID] = (select max(ID) from MyTable)
AND
[OtherColumn] = (1)
GO
And passing the value as a parameter...
CREATE PROCEDURE dbo.GetLatest
@OtherColumn int
AS
SELECT
[Text]
FROM MyTable
WHERE
[ID] = (select max(ID) from MyTable)
AND
[OtherColumn] = @OtherColumn
GO
AHHHHHH, AHHHHHH
-a8le