Click here to Skip to main content
12,065,888 members (26,894 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: ASP.NET SQL-Server
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__ 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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web03 | 2.8.160207.1 | Last Updated 31 Oct 2012
Copyright © CodeProject, 1999-2016
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