How make procedure of below requirement in sql server 2000?

  • Hai Friends,

    I m currently making one web application in that i wanna display details from data base into asp page on grid view.

    create table onward_journey

    (

    onwrd_id int identity,

    request_id int foreign key refernces request(reqst_id),

    from_place varchar(10),

    to_place varchar(10),

    trvael_mode varchar(10),

    no_of_days varchar(10)

    )

    insert into onward_journey ('11','chennai','chenai','car','2')

    i wanna display display my page on gridview

    select

    from_place,to_place,travel_mode, no_of_days from travel_request where request_id=IDENT_CURRENT ('request')

    when i made new request also its showing old once? how to that and how to show current request_id value?

  • It isn't clear if you are working with SQL Server 2000 or SQL Server 2008. I'm not sure if IDENT_CURRENT function existed in SQL Server 2000 and I can't check it right now. In any case if you are using it, the function needs the table's name as an input. In your example the table's name is onward_journey but in your code you are using a different name as parameter. If you don't get null it could be because you have another table with that name and identity column. Another error that you have is that you compare the value of the column request_id to the value that the function returns, but in the table definition the identity column is called onwad_id.

    Adi

    --------------------------------------------------------------
    To know how to ask questions and increase the chances of getting asnwers:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • I believe the IDENT_CURRENT Function did exist in Sql Server 2000 but do bear in mind that it will return the last identity value generated for a specified table in ANY session or scope so it may not be what you are after.

    Clarify if you are working with SQL Server 2000 or 2008 here as there may be alternative ways to do what you want.

  • Hai friends

    i ve three tables like

    create table users

    (

    user_id int,

    username varchar(10),

    password varchar(10)

    )

    insert into users values('0001','ram','ram@123')

    if the person enter the travel purpose on my web page automatcially store the information on travel_request

    create table travel_request

    (

    request_id int identity pk,

    user_id int fk refernces users(user_id),

    purpose_of_travel varchar(10),

    total_amount varhcra(10),

    is_draft varchar(10)

    )

    request_id user_id purpose_of_travel total_amount is_draft

    1 0001 company visit 5000 null

    (if i m choose save means is_draft ll updated on "yes")

    next i ve created day wise travel plan if i m entered it ll stored on

    onward_journey table.

    create table onward_journey

    (

    onward_journey_id int identity,

    request_id int FK references travel_request(request_id),

    depdate datetime,

    from_place varchar(10),

    to_place varchar(10),

    travel_mode varchar(10)

    )

    after added the value ll show like these

    onwa_id deptdate from_place to_place travel_mode request_id

    1 01-jul-2013 chennai chennai car 1

    2 02-jul-2013 chennai Banglore train 1

    select

    onward_journey_id,

    convert(varchar, departuredate, 106)as DepartureDate,

    from_location,

    to_location

    from

    onward_journey

    where

    request_id = ident_current('travel_request')

    is thes code correct ah? its returning previous value

    now i wanna make procedure depends on request_id

    i need to display code for new request means empty ?

  • Your question is very unclear. It is nearly impossible to figure out what your question is. I don't think you want to use IDENT_CURRENT. If you have two users at the same time and they both enter a request you may show a request for a different user.

    The ddl you posted is full of syntax errors. It really doesn't help too much if the ddl you post doesn't work.

    Please take the time to post something usable and then a clear explanation of what you want as output.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply