Quantcast
Channel: ฟอรัม Getting started with SQL Server
Viewing all articles
Browse latest Browse all 8428

Insert values into a table with multiple select query

$
0
0

Hi,

I have a table called MailTo, Below is the structure of the table.

To the To_mail column i should insert mail ids from a multiple select queries. Below are the two queires where i get two mail IDS and one ID will be hardcoded. 

(select main_usr_email from tbl_main_usrs where main_usr_id_pk = @userid )

(Select  email from v_empSup  where usr_id  = @sessionUserID )

'XJAWebmaster@wabtec.com'

These are the IDS to be inserted into Mailto table . Please help me out with this

Create table Mail
(
Mail_ID          int IDENTITY Primary KEY   ,
USERID           int,
[Type]           varchar(100),
FirstName        varchar(50),
LastName         varchar(50),
WeekEndDate      DateTime,
MFirstName       varchar(50),
     MLastName        varchar(50),
Body             varchar(4000),
[Subject]        varchar(250),
--To_Mail          varchar(500),
From_Mail        varchar(100),
[Status]         BIT,
Customer         varchar(50),
Cfield_name      varchar(200),
JobID            INT,
InsertDate       Datetime NOT NULL DEFAULT getdate(),
MailUpdateDate   Datetime,
MailSendDate     DateTime,
    );
 

 Create table MailTo 
 (
 Mail_ID int,
 To_mail varchar(100),
 Type    varchar(10),
 FOREIGN KEY(Mail_ID) REFERENCES mail(Mail_ID)
 )


Deepa


Viewing all articles
Browse latest Browse all 8428

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>