467,915 Members | 1,289 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,915 developers. It's quick & easy.



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
  • viewed: 1097
3 Replies
Expert 2GB
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
Thanx for the reply. I do it all in one execution.
Dec 3 '08 #3
Expert 2GB
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.

Similar topics

6 posts views Thread by Paolo Losi | last post: by
2 posts views Thread by Jenny Zhang | last post: by
5 posts views Thread by Johannes Lebek | last post: by
75 posts views Thread by Beni | last post: by
2 posts views Thread by Ina Schmitz | last post: by
2 posts views Thread by abhaybhat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.