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

 All Forums
 Old Forums
 CLOSED - General SQL Server
 insert select statement
 Forum Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Ask SQLTeam Question

0 Posts

Posted - 01/15/2003 :  14:56:50  Show Profile  Visit AskSQLTeam's Homepage
Janice writes "not certian how to script the following:
trying to insert records into TABLE_A, which has three values. The tricky part is one value is the result of a select statement on TABLE_B. For example

Insert TABLE_A (thing, personorgroup, accessrights)
Values ('unknown', '998', '255')

the unknown is the results from:
(select * from TABLE_B where author = '12067'
and default_rights = '1')
This totals approx 400 records so need to insert a record into TABLE_A for each of the 400 using the values above.
Can anyone help?
Using SQL Server 2000, OS is WIN2K"

Yak Posting Veteran

New Zealand
85 Posts

Posted - 01/15/2003 :  16:25:28  Show Profile
This should do it:

Insert Into TABLE_A
(thing, personorgroup, accessrights)
<name of field from TABLE_B>, '998', '255'
where author = '12067'
and default_rights = '1'

Just replace <name of field from TABLE_B> with the name of the
field in table_B which holds the value of thing

Go to Top of Page
  Previous Topic Topic Next Topic  
 Forum Locked
 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