Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL-Server ASP:NET
Hi,
 
I have two tables the SQL database, a user table and the user_events table .On button click i need to retrieve userid from user table and insert into a column in the user_events table.Can anyone tell me how to achieve the task on asp button click. I would be thankful if anybody suggest me an alternative for this.
Posted 31-Oct-12 2:30am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Try this :
INSERT INTO UserEvents(UserId)
SELECT UserId
FROM User
WHERE UserName='XXX'
 
Have a look at :http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/[^]
this might help you
  Permalink  
Comments
__TR__ at 20-Nov-12 2:52am
   
5ed!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

This could be one way to do this:
 
SELECT *
INTO Persons_Backup
FROM Persons
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 495
1 Maciej Los 340
2 Richard MacCutchan 265
3 BillWoodruff 225
4 Mathew Soji 200
0 OriginalGriff 8,804
1 Sergey Alexandrovich Kryukov 7,457
2 DamithSL 5,689
3 Maciej Los 5,279
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web02 | 2.8.1411028.1 | Last Updated 31 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100