[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Mixing constants with INSERT INTO

Posted on 2011-09-21
2
Medium Priority
?
233 Views
Last Modified: 2012-05-12
I have values from a temp table that need to be inserted into an existing table.  However, I will hard code some of the values going in.  How do I mix these hard coded values with the INSERT INTO...SELECT?  Or is a different technique needed?
0
Comment
Question by:brettr
[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 14

Accepted Solution

by:
mds-cos earned 1000 total points
ID: 36577415
No problem!  You just can't wildcard the fields.

INSERT INTO intable (infield1, infield2, infield3, ...)
SELECT outfiled1, outfield2, 'hardcode',...
FROM outtable
0
 
LVL 93

Assisted Solution

by:Patrick Matthews
Patrick Matthews earned 1000 total points
ID: 36577418
No problem:

INSERT INTO SomeTable (col1, col2, col3, col4)
SELECT x, y, 'Fred', 123
FROM #my_temp

Open in new window


First two columns from the temp table, last two as constants.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

649 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