SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    May 2013
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Stored procedures using ms sql and asp

    SET QUOTED_IDENTIFIER ON SET ANSI_NULLS ON
    GO

    CREATE Procedure up_new_profile
    (
    @member_id int,
    @active bit,
    @market varchar(50), ' Does this part of code values need to equal the exact code values in values section in code?
    @salutation varchar(25),
    @suffix varchar(25), ' @suffix varchar(25), and @suffix or can it equal @strsuf?
    @snfname varchar(75),
    @snlname varchar(75),
    @profile_id int output
    )
    as
    insert into profile(
    member_id,
    active,
    market,
    salutation,
    suffix,
    snfname,
    snlname,
    )
    values(
    @member_id,
    @stractive
    @strmakt ' Does this part of code values need to equal the exact code values in values section in code?
    @strsal
    @strsuf ' @suffix varchar(25), and @suffix or can it equal @strsuf?
    @strsfn
    @strsln
    )

    select @profile_id = @@identity
    GO
    SET QUOTED_IDENTIFIER OFF SET ANSI_NULLS ON
    GO

    Thanks in advance

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,220
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    i will guess that the answer is no

    what happened when you tested it?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Member
    Join Date
    May 2013
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    While running it in Query Analyzer I get the following error:

    Incorrect syntax near ','. Incorrect syntax near the keyword 'print'. Must declare the scalar variable "@profile_id".

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,220
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    okay, i ~think~ that i now understand what you were asking

    yes, the variable names have to be the same in both places
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  5. #5
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would advise you to read up about

    @@identity, SCOPE_IDENTITY() and IDENT_CURRENT(‘tablename’)

    http://blog.sqlauthority.com/2007/03...ity-of-record/


Bookmarks

Posting Permissions

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