Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

INSERT INTO SELECT

Posted on 2009-02-12
7
Medium Priority
?
492 Views
Last Modified: 2012-05-06
Hi,

Is there any way to perform an insert into select statement and add another column? Something like the code below?
insert into UserofFile (fileid,title,subtitle,nameoffile,date,category, FileUser) 
select fileid,title,subtitle,nameoffile,date,category from FileViewer where nameoffile = 'install_flash_player.exe', 'Uers'

Open in new window

0
Comment
Question by:JeffEae
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 37

Expert Comment

by:momi_sabag
ID: 23622670
insert into UserofFile (fileid,title,subtitle,nameoffile,date,category, FileUser)
select fileid,title,subtitle,nameoffile,date,category from FileViewer where nameoffile in ( 'install_flash_player.exe', 'Uers')
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 23622672
You can simply add a literal to the list of fields:

insert into UserofFile (fileid,title,subtitle,nameoffile,date,category, FileUser)
select fileid,title,subtitle,nameoffile,date,category, 'Someliteral' from FileViewer where nameoffile = 'install_flash_player.exe'

0
 
LVL 37

Expert Comment

by:momi_sabag
ID: 23622680
you did not specify a value for fileuser
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 57

Accepted Solution

by:
Raja Jegan R earned 2000 total points
ID: 23622682
This will do..
Slight change in syntax
insert into UserofFile (fileid,title,subtitle,nameoffile,date,category, FileUser) 
select fileid,title,subtitle,nameoffile,date,category, 'Uers'
from FileViewer 
where nameoffile = 'install_flash_player.exe'

Open in new window

0
 

Author Comment

by:JeffEae
ID: 23622781
Thank you
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 23622799
Erm, how was rrjegan17s' answer any different to mine?
0
 
LVL 57

Expert Comment

by:Raja Jegan R
ID: 23622822
carl_tawn,
    You are also correct, but I pointed him where he did the mistake using his syntax itself and hence the user fixed his issue at the earliest.
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

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 ?
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
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.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Suggested Courses

580 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