468,539 Members | 1,618 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,539 developers. It's quick & easy.

Incorrect syntax near the keyword 'Declare'.

Dear Group,

I am trying to create a view and keep getting the Incorrect syntax near the
keyword 'Declare'" error.

Here is the code I am writing.

Create view fixed_airs (sid, fad_a2, fad_a3) as
Declare @sid int,
@fad_a2 int,
@fad_a3 int
select @sid=cast(substring(subject_id,1,8)as int) ,
@fad_a2 =cast (substring(fad_2_4,1,1) as int),
@fad_a3=cast(substring(fad_2_4,2,1) as int)
from parentpacket.

Thanks for the help in advance.

Jeff Magouirk
Jul 23 '05 #1
1 12458
nib
Jeff Magouirk wrote:
Dear Group,

I am trying to create a view and keep getting the Incorrect syntax near the
keyword 'Declare'" error.

Here is the code I am writing.

Create view fixed_airs (sid, fad_a2, fad_a3) as
Declare @sid int,
@fad_a2 int,
@fad_a3 int
select @sid=cast(substring(subject_id,1,8)as int) ,
@fad_a2 =cast (substring(fad_2_4,1,1) as int),
@fad_a3=cast(substring(fad_2_4,2,1) as int)
from parentpacket.

Thanks for the help in advance.

Jeff Magouirk


You keep getting syntax errors because you're using illegal syntax in
your CREATE VIEW statement. :D You can't use DECLARE, nor can you pass
in variables to a view. Check Books Online for proper syntax. But, in a
nutshell, you can only use a SELECT statement in a view.

Zach
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by Mark Findlay | last post: by
1 post views Thread by Sandesh | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.