Solved

select into same table syntax

Posted on 2006-06-23
2
230 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 500 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
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 ?
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

726 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