Click here to Skip to main content
15,036,823 members
Please Sign up or sign in to vote.
0.00/5 (No votes)

I am doing an attendance system based on fingerprint.
When i put a finger on fingerprint reader,the system will identify the scanned fingerprint from database.
What i want to do is if the fingerprint is match, then get the related data like employeeID,employeeName,currentDate based on the fingerprint's ID from table Fingerprint and insert into table attendance.

May i know Is it use insert into select?

Thanks for help.
Amir Mahfoozi 20-Dec-11 6:00am
What do you mean by saying "May i know Is it use insert into select?" ?

T-SQL allows you to use a SELECT as part of the INSERT statement, so you can do something like:
INSERT INTO MyTable(EmpID, EmpName, CurrentDate)
SELECT FullEmployeeID, EmployeeName, GETDATE()
FROM MyOtherTable
WHERE SomeCriteria = @PassedInCriteria
Member 6530594 27-Oct-13 4:02am
@PassedInCriteria, this Parameter, how to pass in the from vb code to SP?
Member 6530594 27-Oct-13 4:04am
@PassedInCriteria, this Parameter, how to pass in the from vb code to SP?
my e-mail,
write stored procedure for this.

declare local variable first.

select the data from 1st table and asssign then to the local variables

and write the insert query with the local variables

thats it..
Pete O'Hanlon 19-Dec-11 11:40am
Why? This is not the most efficient way of solving the problem, especially considering that T-SQL provides the tools built in to support what the OP needs to do without having to create temporary variables.

INSERT INTO dbo.table1 (Col1,Col2,col3)
SELECT Col1,Col2,col3
FROM Table2 
WHERE Conditions

So Table2 values will insert in Table1....
Karthik Harve 20-Dec-11 6:55am
[Edit] Added pre tags.
Pete O'Hanlon 20-Dec-11 6:58am
How is this any different to the solution I posted yesterday?

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

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900