SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Insert Select statement
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

oceanboy
Starting Member

Taiwan
44 Posts

Posted - 06/13/2007 :  03:47:50  Show Profile  Reply with Quote
Hello~

The task I want to do here is kind of strange but I wonder whether i can do so

I have a table with the following columns:
ID as int , DESCRIPTION as nvarchar, VALUE as nvarchar

Then i will populate the table with the following statement:

insert into id, value
select id, price from table a inner join table b 
on a.xx = b.xx

However, I would like to fill in the DESCRIPTION with the word "Average". Is it possible to do so while I INSERT#12288;INTO that table instead of using UPDATE statement?

One thing to bear in mind that this table will not be used only by 1 process but the others. Therefore the VALUE column doesnt not only store price but also other information. That's why the DESCRIPTION column is there.

Thus, the table will look like this
1 Average 5
2 Average 4
3 Average 5
1 Discount 5
3 Discount 1

Thanks in advance!

SwePeso
Patron Saint of Lost Yaks

Sweden
30281 Posts

Posted - 06/13/2007 :  03:55:31  Show Profile  Visit SwePeso's Homepage  Reply with Quote
Yes.

INSERT INTO NewTable (ColA, ColB, ColC) SELECT Col1, 'Average', ColGreen FROM OldTable


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

oceanboy
Starting Member

Taiwan
44 Posts

Posted - 06/13/2007 :  04:11:16  Show Profile  Reply with Quote
coolio! I thought it could work and you have proved me right! Thanks a zillion!
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000