Click here to Skip to main content
11,495,945 members (62,912 online)
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 Dnyaneshwar@Pune 692
1 CHill60 318
2 Sascha Lefèvre 235
3 RyanDev 230
4 _Asif_ 155
0 Sergey Alexandrovich Kryukov 10,372
1 OriginalGriff 8,871
2 Sascha Lefèvre 3,899
3 Maciej Los 3,422
4 Richard Deeming 2,600


Advertise | Privacy | Mobile
Web04 | 2.8.150520.1 | Last Updated 31 Oct 2012
Copyright © CodeProject, 1999-2015
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