By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,659 Members | 1,678 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,659 IT Pros & Developers. It's quick & easy.


P: 9

The sql script i try to execute in c# code fails to insert data in table but no error occurs. If I copy the sql code right before execution and paste it into the management studio it works fine. The script looks something like this.

create table #tempHolder1(RecipientID int, SMSMessageQueueID int)
create table #tempHolder2(SMSMessageQueueID int, RecipientID int, SMSResponseText nvarchar(32), ResponseDate datetime)

insert into #tempHolder1 select RecipientID, SmsMessageQueueID from tSmsMessageSendInfo where DestinationNumber = @mobileNumber
and SMSMessageQueueID in (select SMSMessageQueueID from tSMSMessageQueue where IRP = @irpID)

insert into #tempHolder2 (SMSMessageQueueID, RecipientID)
select SMSMessageQueueID, RecipientID from #tempHolder1

update #tempHolder2 set SMSResponseText = @smsResponseText, ResponseDate = @responseDate

insert into tSmsResponse (SMSMessageQueueID, RecipientID, SMSResponseText, ResponseDate)
select * from #tempHolder2

drop table #tempHolder1
drop table #tempHolder2
Dec 3 '08 #1
Share this Question
Share on Google+
3 Replies

Expert 2.5K+
P: 2,878
The only reason I can't think of is because of your temp table.I don't know how you executed the entire code, if this is a single batch or one code at a time.

-- CK
Dec 3 '08 #2

P: 9
Thanx for the reply. I do it all in one execution.
Dec 3 '08 #3

Expert 2.5K+
P: 2,878
Try using a table variable or a physical table instead.

-- CK
Dec 3 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.