SQL Syntax Error???

M

munkis29

Hey All,

I wrote this code in SQL View Query window but when I try to save it, I
get an error box that says "Syntax Error in FROM clause" I've tried a
few different variations in the syntax but still to no avail. Hopefully
someone can look this over and tell me what I'm doing wrong, thanks in
advance. (Using Access 2003 by the way)

SELECT FileID FROM Test2
DECLARE @test AS int, @ctr AS int
SET @test = FileID
SET @ctr = .1

IF @test = FileID
SET FileID = FileID + ctr
SET @ctr = @ctr + .1
ELSE
SET @ctr = .1
END IF;
 
D

Danny J. Lesandrini

First, this only runs on SQL Server. Access doesn't support any of this.
Second, the correct syntax is ...

SELECT FileID FROM Test2
DECLARE @test AS int, @ctr AS int
SET @test = FileID
SET @ctr = .1

IF @test = FileID
begin
select FileID = FileID + ctr
select @ctr = @ctr + .1
end
ELSE
SET @ctr = .1

My edits are in lower case and I deleted the END IF.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top