i shortned this procedure. but im havving problems with the like clause in this, it says it cannot find the column which i dont understand
CREATE PROC spBalanceRange
@VendorVar VARCHAR(50) = NULL,
AS
DECLARE @QUERY VARCHAR(1000)
SET @QUERY = 'SELECT VendorName, InvoiceNumber, PaymentTotal AS Balance
FROM Invoices JOIN Vendors
ON Invoices.VendorID = Vendors.VendorID '
IF @VendorVar IS NOT NULL
SET @QUERY = @QUERY + 'WHERE VendorName LIKE ' + @VendorVar + ') '
SET @QUERY = @QUERY + ' ORDER BY PaymentTotal DESC'
EXEC (@QUERY)
CREATE PROC spBalanceRange
@VendorVar VARCHAR(50) = NULL,
AS
DECLARE @QUERY VARCHAR(1000)
SET @QUERY = 'SELECT VendorName, InvoiceNumber, PaymentTotal AS Balance
FROM Invoices JOIN Vendors
ON Invoices.VendorID = Vendors.VendorID '
IF @VendorVar IS NOT NULL
SET @QUERY = @QUERY + 'WHERE VendorName LIKE ' + @VendorVar + ') '
SET @QUERY = @QUERY + ' ORDER BY PaymentTotal DESC'
EXEC (@QUERY)