Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

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

Starting Member

44 Posts

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

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!

Patron Saint of Lost Yaks

30421 Posts

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

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

Peter Larsson
Helsingborg, Sweden
Go to Top of Page

Starting Member

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  
 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.02 seconds. Powered By: Snitz Forums 2000