Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

select into same table syntax

Posted on 2006-06-23
2
Medium Priority
?
243 Views
Last Modified: 2008-03-03
Hi,
I'm wondering if there is a way to select rows that match a criteria and copy back into the same table.
All copied data would be the same as the original except for 2 columns which would then be specified.
thanks
0
Comment
Question by:dgrafx
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 2000 total points
ID: 16968461
Something like:

    INSERT INTO YourTable (FirstName, LastName, Age)  SELECT FirstName, 'Smith', Age FROM YourTable;

Will select FirstName and Age from YourTable, but will give each copied record a value of "Smith" for LastName.
0
 
LVL 25

Author Comment

by:dgrafx
ID: 16968536
I don't even know what I'm talking about.
Got confused asking this question ...
What I was doing was selecting from table a certain criteria -
then I did an insert query using data from first query going row by row -
knew this seemed inefficient ..
I'm on my first cup of coffee - rough night ...
As soon as I read your response I said "Idiot!"
I just need to insert and select using the criteria from the first query - eliminating the first query altogether.
easy as cake
thanks for pointing this out and I won't post again until I'm on second cup (of coffee)
0

Featured Post

How Blockchain Is Impacting Every Industry

Blockchain expert Alex Tapscott talks to Acronis VP Frank Jablonski about this revolutionary technology and how it's making inroads into other industries and facets of everyday life.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question