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

x
?
Solved

How so select a value into a table, if the source table does not contain the value

Posted on 2015-02-06
3
Medium Priority
?
208 Views
Last Modified: 2015-02-07
I am selecting data from a temp table "#TEMP_TABLE" into another table "ADMIN_USERS" which is not temporary.
The temp table does not have one of the column values I need to insert into the database table "ADMIN_USERS".
The column that is missing from the temp table is named "SERVER_NAME", and is a non null field. I would like to just insert the word/name
"Practice Server" into this field. How can I do that? Can it be done in the select statement?


INSERT INTO ADMIN_USERS (
ASSOCIATE_NUMBER
FIRST_NAME
MIDDLE_NAME
LAST_NAME
SERVER_NAME -- Somehow set this field to the text "Practice Server". I don't know how to do it though??.
AGE
)
SELECT
ASSOCIATE_NUMBER
FIRST_NAME
MIDDLE_NAME
LAST_NAME
AGE
FROM #TEMP_TABLE
0
Comment
Question by:brgdotnet
[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
3 Comments
 
LVL 66

Accepted Solution

by:
Jim Horn earned 1840 total points
ID: 40595175
Yes, just add the string..
INSERT INTO ADMIN_USERS (ASSOCIATE_NUMBER, FIRST_NAME, MIDDLE_NAME, LAST_NAME, SERVER_NAME, AGE)
SELECT ASSOCIATE_NUMBER, FIRST_NAME, MIDDLE_NAME, LAST_NAME, 'Practice Server', AGE
FROM #TEMP_TABLE

Open in new window

0
 
LVL 11

Assisted Solution

by:HuaMinChen
HuaMinChen earned 160 total points
ID: 40595277
Try
INSERT INTO ADMIN_USERS (
ASSOCIATE_NUMBER,
FIRST_NAME,
MIDDLE_NAME,
LAST_NAME,
SERVER_NAME, -- Somehow set this field to the text "Practice Server". I don't know how to do it though??.
AGE
)
SELECT
ASSOCIATE_NUMBER,
FIRST_NAME,
MIDDLE_NAME,
LAST_NAME,
'Practice Server',
AGE
FROM #TEMP_TABLE

Open in new window

0
 
LVL 2

Author Closing Comment

by:brgdotnet
ID: 40595738
Jim was first by about an hour, so I am giving him most of the points. Thanl you.
0

Featured Post

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

730 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