July 20, 2008 at 5:44 am
Hi All,
I have a situation here for inserting one value in my existing record. here is the situation:
ID Col1 Col2 Col3
A12 NULL NULL A12.htm
A34 NULL NULL A34.htm
A56 A90 NULL A56.htm
A78 NULL NULL A78.htm
A90 NULL A56 A90.htm
I have a form to insert the record, where some time user have to select the value for Col2, In this situation If the Col2 receive any value then I want to insert the ID of that record in Col1 infront of the same value which the user has selected for Col2 (As mentioned above).
Value for Col2 can only selected from a drop down existing record. That means user can only insert the value in Col2 from the existing record.
i hope that experts understand what I am looking for.
Thanks for any help.
July 20, 2008 at 11:08 am
No - don't understand what you are asking. Please read the following article and re-post your question:
Best Practices: http://www.sqlservercentral.com/articles/Best+Practices/61537/
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
July 21, 2008 at 1:16 am
As far as I understood your problem,
1. you need insert a record
2. you need to update the record according to the SELECTED ID
whats the problem in it...?
say, user Inserts record 'A101',NULL, 'A34','A101.htm'
After Inserting this record, you need to update the ID 'A34'
Update YourTable
Set Col1 = 'A101'
Where ID = 'A34'
if you are worried about the IDs, you calready have the ID 'A34' (as it has been selected from your form)
Another ID is 'A101'. Now this depends upon your PK generation logic. You have to have it in a variable while you are INSERTING the record.
I hope it will help you.
Atif Sheikh
July 21, 2008 at 3:05 am
As per my understanding what you have to do is create an Update trigger on your table, where you have build a logic to update col1
if Col2 is updated then take the record from inserted & deleted tables. and update inserted Col2 (value) record with deleted ID. You can get the Col2 recordID from inserted table and ID recordID from deleted table.
July 21, 2008 at 3:48 am
Thanks to all. I already solved the issue by using insert and update. Before I was just using the insert statement. it was really very simple, as mentioned by you guys.
Thanks a lot for help.
July 21, 2008 at 5:06 am
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply