Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Kervin
Starting Member
12 Posts |
Posted - 2003-08-13 : 06:01:14
|
| Hi...First some background into what I am doing.I am paging through recordsets in ASP by creating a temp table in a stored procedure that returns the portion of the recordset needed for that page. To populate the temp table I :INSERT INTO #TempTable (field1,field2,field3)SELECT ...The results of the select statement are used as the VALUES to insert.This has worked well... but now I want to create a temp table that is populated with information form 2 different select statements. The fields in both select statements are only slightly different so I would like to have it all put into the same temp table ( this will also allow me to know the correct number of total records created - remember I am using this to page through the recordset ).The Problem: I want to insert a field value ( not part of the select query ) to indicate to me which select statement was used to create the current record being read from the recordset(for use on the asp side of the code) I read that I cant have the select statement as one of the values in the VALUES clause of the INSERT statement (that was my first idea)...ie:INSERT INTO #TempTable (field1,field2,field3)VALUES('Created by select #1',SELECT...)is a no-no...Any Idea how I should be doing this?ThankxKervin.kervin_findlay@hotmail.com |
|
|
AndrewMurphy
Master Smack Fu Yak Hacker
2916 Posts |
Posted - 2003-08-13 : 06:29:54
|
| insert into table1 (specialfield1, datafield1, datafield2, datafield3)select 1, dataitema1, dataitema2, dataitema3 from tablea where etcunionselect 2, dataitemb1, dataitemb2, dataitemb3 from tableb where etcshould work |
 |
|
|
mr_mist
Grunnio
1870 Posts |
Posted - 2003-08-13 : 06:32:13
|
| You've got it slightly wrongly written..INSERT INTO thingy (moo1, moo2, moo3)SELECT 'yourindicator', field2, field3 FROM yourtableAs in, just put your inicator field into quotes as part of the SELECT.Gah, beaten to it again... :p-------Moo. :) |
 |
|
|
|
|
|
|
|