July 5, 2009 at 8:18 am
I'm getting a incoorect sytax error when trying to ALTER a SP for my project.
The error states that the sytax is not correct near the keyord 'ALL'
Those are two single quotes as: ''All Suppliers'' AS CompanyName
Here's my code:
-- Set up parameter to control type of results to return
-- Default value to 0 for only stored data
@ReturnAllRow bit = 0
AS
-- Determine which version of the query will execute
If @ReturnAllRow = 1 -- ''All Suppliers'' row to be included
BEGIN
ERROR>>>SELECT 0 AS SupplierID, ''All Suppliers'' AS CompanyName
UNION
SELECT SupplierID, CompanyName
FROM Suppliers
ORDER BY CompanyName
END
--No ''All Suppliers'' row to be returned
Else
BEGIN
SELECT SupplierID, CompanyName
FROM Suppliers
ORDER BY CompanyName
July 5, 2009 at 8:49 am
anything in double quotes or square brackets are expected to be a column name, not a static value:
SELECT 0 AS SupplierID, "All Suppliers" AS CompanyName
--should be
SELECT 0 AS SupplierID, 'All Suppliers' AS CompanyName
Lowell
July 14, 2009 at 2:34 pm
use 'All Suppliers' if its a static and use [All Suppliers] if its a column name
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply