By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,392 Members | 1,556 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,392 IT Pros & Developers. It's quick & easy.

Specifying Constraints For New Table In SELECT...INTO...

P: 9
Hello All!

Sorry if this is basic, but I'm having trouble finding a way to specify unique fields (like you would ADD CONSTRAINT in an ALTER TABLE statement) for a new table I'm creating with a SELECT / INTO query.

The table is a list containing, among other fields, names of children (fname and lname), their birthdays and ship addresses. I'd like to pull all the fields from the master table into a new table, retaining only one of any possible duplicate entries (children) in the process in the fname, lname and ShipAddress fields.

Put simply, I'm asking if in a statement like:

SELECT master.fname, master.lname, master.shipaddr1 INTO NewTable FROM master

Can constraints be added/specified for tblNewTable?

Any help is greatly appreciated!
Aug 3 '07 #1
Share this Question
Share on Google+
1 Reply


ADezii
Expert 5K+
P: 8,669
Hello All!

Sorry if this is basic, but I'm having trouble finding a way to specify unique fields (like you would ADD CONSTRAINT in an ALTER TABLE statement) for a new table I'm creating with a SELECT / INTO query.

The table is a list containing, among other fields, names of children (fname and lname), their birthdays and ship addresses. I'd like to pull all the fields from the master table into a new table, retaining only one of any possible duplicate entries (children) in the process in the fname, lname and ShipAddress fields.

Put simply, I'm asking if in a statement like:

SELECT master.fname, master.lname, master.shipaddr1 INTO NewTable FROM master

Can constraints be added/specified for tblNewTable?

Any help is greatly appreciated!
You can use the UniqueValues property when you want to omit records that contain duplicate data in the fields displayed in Datasheet view. For example, if a query's output includes more than one field, the combination of values from all fields must be unique for a given record to be included in the results. The DISTINCT Predicate corresponds with the Unique Values Property as in:
Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT master.fname, master.lname, master.shipaddr1 INTO NewTable FROM master
Aug 4 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.