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

    Unanswered: exec sproc in sproc

    create procedure dbo.GetZipID( @City varchar(30), @State char(2), @Zip5 char(6))
    as
    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
    set @CityID= EXEC GetCityID(@City);
    set @StateID= EXEC GetStateID(@State);
    insert into ZipCodes(strZipCode,lngStateID,lngCityID) values(@Zip5,@StateID,@CityID)
    if @@ERROR = 0
    SET @ZIPID = @@Identity
    select @ZIPID


    GetCityID and GetStateID are two stored procs, how do I execute those two stored procs
    in the above stored proc? I mean what is the syntax??

    Tks

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    EXEC @CityID = GetCityID(@City)

    Are you using Return in the called sproc to pass out the value?

    Or are you passing back an output variable, if so then


    EXEC GetCityID @City OUTPUT
    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.

  3. #3
    Join Date
    Dec 2003
    Posts
    454
    Why don't you use SELECT clause instead of execute another stored procedure?

    SELECT @StateID = StateID FROM States WHERE State = @State

Posting Permissions

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