views:

802

answers:

1

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.

+17  A: 
INSERT
INTO    tbl_vaucher (vaucher_name, created_date)
SELECT  TOP 1
        con_full_name, GETDATE()
FROM    tbl_contact
Quassnoi
not good, i need exactly that one field be select statement i cant use insert with one select
msony
The answer is right, just try using the select statement in a new query, it will return just what you are looking for.
Mark Dickinson
Yeah a lot of people forget that you can select constants and functions as part of statement as well.
toast
ok, i see that there are no answers, i will use function
msony
@msony - Did you get errors with this answer? Or was the Select statement not correct? I think you can guess from the 15 upvotes that it does work and is correct.. maybe you need to ask your question in a different way.