sql server - Inserting Dataset + additional columns into a table -


this seems pretty straightforward problem life of me, can't seem figure out how this.

i have dataset [a combination of union's] needs inserted table.

dataset:

select col1 a, col2 b, col3 c union select col1 a, col2 b, col3 c 

table structure:

create table tbl1 varchar(50), b varchar(50), c varchar(50), userid varchar(50), timestamp timestamp 

i'm trying:

    insert tbl1 --syntax error here     (select col1 a, col2 b, col3 c         union         select col1 a, col2 b, col3 c) --syntax error here     ,'user'     ,getdate() 

i syntax errors on line select starts , ends [comments]

is there way of doing this?

you're gonna want make union subquery.

insert tbl1 select a, b, c, 'user', getdate() (     select col1 a, col2 b, col3 c     union     select col1 a, col2 b, col3 c ) r 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -