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

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 INSERT date from select table

Author  Topic 

nizguy
Starting Member

37 Posts

Posted - 2011-07-06 : 14:24:13
Hello All, I need your help.

Here is my query:

INSERT INTO Zipcode_new (Zip, Vendor_id, Delivery_Agent)
SELECT z.zip, z.Dlry_Vendor z.Dlry.Vendor
FROM
Zipcode z
WHERE
Zip between '90012' and '95999'


The result from this query:
90012 1263 1263
90013 1263 1263
90014 1263 1263
90015 1263 1263


But I want the second value hard coded to 1000, not from the select result, how can I do that

I want the result look like this
90012 1000 1263
90013 1000 1263
90014 1000 1263
90015 1000 1263


Thank you


visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-07-06 : 14:27:26
INSERT INTO Zipcode_new (Zip, Vendor_id, Delivery_Agent)
SELECT z.zip,1000, z.Dlry.Vendor
FROM
Zipcode z
WHERE
Zip between '90012' and '95999'

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

nizguy
Starting Member

37 Posts

Posted - 2011-07-06 : 14:32:48
That's all. what a dump question

But I tried something similar and it gave me an error


thank you
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-07-06 : 14:35:14
you were missing a comma too in your posted code. may be thats the reason

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -