SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


How make procedure of below requirement in sql server 2000?


How make procedure of below requirement in sql server 2000?

Author
Message
raghuldrag
raghuldrag
SSC Veteran
SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)

Group: General Forum Members
Points: 232 Visits: 473
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?
Adi Cohn
Adi Cohn
Hall of Fame
Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)

Group: General Forum Members
Points: 3805 Visits: 6513
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/
OTF
OTF
Mr or Mrs. 500
Mr or Mrs. 500 (520 reputation)Mr or Mrs. 500 (520 reputation)Mr or Mrs. 500 (520 reputation)Mr or Mrs. 500 (520 reputation)Mr or Mrs. 500 (520 reputation)Mr or Mrs. 500 (520 reputation)Mr or Mrs. 500 (520 reputation)Mr or Mrs. 500 (520 reputation)

Group: General Forum Members
Points: 520 Visits: 4128
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.
raghuldrag
raghuldrag
SSC Veteran
SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)

Group: General Forum Members
Points: 232 Visits: 473
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 ?
Sean Lange
Sean Lange
One Orange Chip
One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)

Group: General Forum Members
Points: 27392 Visits: 17557
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.

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)
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search