Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

How make procedure of below requirement in sql server 2000? Expand / Collapse
Author
Message
Posted Wednesday, July 24, 2013 4:13 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, March 24, 2014 5:52 AM
Points: 160, Visits: 399
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?
Post #1476962
Posted Wednesday, July 24, 2013 4:23 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Wednesday, April 16, 2014 5:39 AM
Points: 2,104, Visits: 5,378
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/
Post #1476965
Posted Wednesday, July 24, 2013 4:38 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Thursday, October 31, 2013 3:44 AM
Points: 314, Visits: 4,128
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.
Post #1476969
Posted Wednesday, July 24, 2013 4:52 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, March 24, 2014 5:52 AM
Points: 160, Visits: 399
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 ?



Post #1476977
Posted Wednesday, July 24, 2013 7:55 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 2:49 PM
Points: 12,016, Visits: 11,046
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 Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1477072
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse