Results 1 to 2 of 2
  1. #1
    Join Date
    May 2003
    Posts
    40

    Unanswered: sproc in a sproc

    create procedure
    GetAddress(@Addr1 varchar(40), @Addr2 varchar(40), @City varchar(30), @State char(2), @Zip5 char(6), @Zip4 smallint)
    as
    begin
    declare @ZipID integer
    declare @AddrID integer
    set @AddrID=1
    if lTrim(@Addr1)<>''


    EXEC @ZipID= dbo.GetZipID(@City,@State,@Zip5)


    set @AddrID = (select Min(lngAddrID) from dbo.Addrs where lngZipCodeID=@ZipID and Address1=@Addr1 and Address2=@Addr2)
    return(@AddrID)
    end
    GO




    In the above sproc I m trying to call another sproc GetZipID . Its giving me an error stating that

    "Incorrect syntax near @City. "

    Can you help me out? The same syntax works for passing one variable but not for three.

    FYI this is the other sproc




    CREATE PROCEDURE dbo.GetZipID(@City varchar(30), @State char(2), @Zip5 char(6))
    AS
    BEGIN
    DECLARE @CityID integer
    DECLARE @StateID integer
    DECLARE @ZipID integer

    SET @ZipID=2
    set @Zip5=lTrim(@Zip5)
    if @Zip5<>''
    SET @ZIPID = (select Min(lngZipCodeID) AS ZipID from ZipCodes where strZipCode=@Zip5)
    if @ZipID is null

    EXEC @CityID = dbo.GetCityID @City
    EXEC @StateID = dbo.GetStateID @State

    insert into ZipCodes(strZipCode,lngStateID,lngCityID) values(@Zip5,@StateID,@CityID)
    if @@ERROR = 0
    SET @ZIPID = @@Identity
    Return @ZipID
    print @ZIPID

    END
    GO





    Thx in advance

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Loose the parenthesises
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •