| Author |
Topic |
|
mike123
Master Smack Fu Yak Hacker
1462 Posts |
Posted - 2008-02-13 : 07:28:09
|
I'm trying to do a mass insert into a message table. I'd like to add a bit of customization to the messages inserted, but I'm unsure how to structure the query for this. For example we have the below query which works fine, but I'd like to replace the "_____" with a variable taken from the SELECT query.Thanks very much for any assistance!!appreciated as alwaysmike123INSERT INTO tblMessage (messageTo, messageFrom, message, prevMessage, subject, date, checked, deletedbySender, deletedByRecipient)((select userID, 1, 'hello, ______','','subject', getdate(),0, 0, 0 FROM tblUserDetails )) |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-02-13 : 07:30:04
|
| declare @var varchar(100)SET @Var= 'value'INSERT INTO tblMessage (messageTo, messageFrom, message, prevMessage, subject, date, checked, deletedbySender, deletedByRecipient)((select userID, 1, 'hello,'+@var,'','subject', getdate(),0, 0, 0 FROM tblUserDetails ))where @var is the variable set |
 |
|
|
mike123
Master Smack Fu Yak Hacker
1462 Posts |
Posted - 2008-02-13 : 07:47:06
|
| Hi Visakh16,The value I am trying to insert is actually "nameOnline" which is a value in the table "tblUserDetails"I'm not sure how I would make this work with what I have so far.thanks again,mike123 |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-02-13 : 07:48:58
|
[code]INSERT INTO tblMessage (messageTo, messageFrom, message, prevMessage, subject, date, checked, deletedbySender, deletedByRecipient)select userID, 1, 'hello, ' + nameOnline, '', 'subject', getdate(), 0, 0, 0 FROM tblUserDetails[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
mike123
Master Smack Fu Yak Hacker
1462 Posts |
Posted - 2008-02-13 : 08:10:19
|
| thats it, thank you very much!!mike123 |
 |
|
|
|
|
|