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 2008 Forums
 Transact-SQL (2008)
 Query for insert

Author  Topic 

yukiever
Starting Member

13 Posts

Posted - 2011-02-15 : 15:55:30
Hi everyone,
This query seems to be hard for me. Need help.
I am basically inserting to a table name: maintitemtype
Only two columns are inserted: type, name
'type' column should be always: 'Manufacturer'
'name' column should be a select statement:
SELECT DISTINCT manufacturer FROM MaintItemType WHERE manufacturer is not null

I got something here but not working.
Thanks in advance!


INSERT INTO maintitemtype(type,name) values('Manufacturer')
SELECT DISTINCT manufacturer FROM MaintItemType WHERE manufacturer is not null


jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2011-02-15 : 17:06:15
Almost!
INSERT INTO maintitemtype(type,name)
SELECT DISTINCT 'manufacturer', manufacturer FROM MaintItemType WHERE manufacturer is not null

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

yukiever
Starting Member

13 Posts

Posted - 2011-02-15 : 17:09:15
quote:
Originally posted by jimf

Almost!
INSERT INTO maintitemtype(type,name)
SELECT DISTINCT 'manufacturer', manufacturer FROM MaintItemType WHERE manufacturer is not null

Jim

Everyday I learn something that somebody else already knew



Thanks Jim.
It's working.
Go to Top of Page
   

- Advertisement -