Can I use SELECT statement inside INSERT values?
performance, sql, sql-server-2005, t-sql
Solution
INSERT
INTO tbl_vaucher (vaucher_name, created_date)
SELECT TOP 1
con_full_name, GETDATE()
FROM tbl_contact
Problem
I tried this: ``` INSERT INTO tbl_vaucher ( vaucher_name, created_date ) VALUES ( ( SELECT TOP 1 con_full_name FROM tbl_contact ), GETDATE() ) ``` , getting: `Subqueries are not allowed in this context. Only scalar expressions are allowed`. I need a solution that would work without functions.