hi
how to insert two column values into another column. please give a query of that
means i take firstname and lastname and username in my table
username = firstname + lastname
how to write insert statement
all values are inserted same time
thanks.
Loading
ajay rajuPosted Mar 31, 2010, 1:59 AM
i find the solution of insert two column values into one column i.e., simple below is the code
create table users (firstname varchar(50), lastname varchar(50), username as lastname + ' ' + firstname)
insert into users values('Ajay','Kalidindi') // no need to write username column information it is automatically generated.
Thanks
Hirendra SisodiyaPosted Mar 30, 2010, 9:24 AM
i think we can not insert two coloumn value in to another column in single query. we can use update query after insert both values,this is very easy if your table has any identity column or any primary value like:
insert query: insert into table(name1,name2) values(" Ajay ", " Raju ")
update query: update table set name3=name1+name2 where id=(select max(id) from table)
thanks
Please mark as answere if it helps
Jaish MathewsPosted Mar 30, 2010, 9:22 AM
Why can't you take a variable and store firstname + lastname. Then pass firstname,lastname and this new variable to a stored Procedure