﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2005 / T-SQL (SS2K5)  / Using the recordset from SELECT statement in an INSERT statement, all in one Stored Procedure / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Wed, 19 Jun 2013 18:24:40 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Using the recordset from SELECT statement in an INSERT statement, all in one Stored Procedure</title><link>http://www.sqlservercentral.com/Forums/Topic475307-338-1.aspx</link><description>Something like this:[code]INSERT INTO LOGLOG (destination, [content])	SELECT phonenumber, 'hello world'	FROM USERLIST	where OWNERNAME LIKE @name[/code]John</description><pubDate>Thu, 27 Mar 2008 05:23:21 GMT</pubDate><dc:creator>John Mitchell-245523</dc:creator></item><item><title>Using the recordset from SELECT statement in an INSERT statement, all in one Stored Procedure</title><link>http://www.sqlservercentral.com/Forums/Topic475307-338-1.aspx</link><description>Hi, i'm an SQL newbie.  I'm trying to figure out if there's an easy way to take a single field record set from a SELECT statement and then do an INSERT using that record set, all in one single Stored Procedure.Here's what i tried to do, but this returns an error "The name "phonenumber" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.".The common field in both SELECT and INSERT is phonenumber.[quote]PROCEDURE [dbo].[usp_select_and_insert]   @name varchar(20),ASSELECT [b]phonenumber[/b] FROM USERLIST where OWNERNAME LIKE @nameINSERT INTO LOGLOG (destination,content) values([b]phonenumber[/b],'hello world');GO[/quote]Hope that one of you can be kind enough to give me some guidance.  Appreciate in advance.  :)</description><pubDate>Thu, 27 Mar 2008 04:59:51 GMT</pubDate><dc:creator>joshua__lim</dc:creator></item></channel></rss>