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

Select and Insert statements in Sql server 2005 stored procedure

$
0
0

Hello,

I'm  using SQL Server 2005 - stored procedures.

Stored procedure - select statement :

-----------------------------------------

The select statement inside the stored procedure doesn't return any result set to my front end client coldfusion page even empty result set also. I put @@error variable after the select statement , but no error as well as no result set is returned.

Please if any one experienced this case, help me please.......

 

Stored procedure - Multiple Insert statements :

---------------------------------------------------

In my application I have 4 tables Customers, CustomerDetails, CustomerNotes, CustomerPhonenumbers related to "Customer" . I'm taking data from table 'Mail_Incoming' and inserting the available data from Mail_Incoming table into 4 tables.

But some times I have found one issue.

The order of insert statements and @@error variable in my stored procedure is as foolows:

-------------------------------

---> Inserting data into 'Customers' table

if @@error <> 0 return -1

---> Inserting data into 'CustomerDetails' table

if @@error <> 0 return -1

---> Inserting data into 'CustomerNotes' table

if @@error <> 0 return -1

---> Inserting data into 'CustomerPhonenumbers ' table

---------

In the above 4 insert statements some times the 2nd insert statement into Customerdetails table is not getting inserted and the 3rd and 4th statements are executed and the records are inserted into tables 'CustomerPhonenumbers ' and

'CustomerPhonenumbers ' tables.

I don't know what was the error?

If this is really an error the variable @@error after the 2nd insert statement shoud containn value greater than 0 and the next two insert statements should never get executed.

One more point here is, the records from mail_incoming table are proccessed by .NET webservice simultaneously one after the other. May be due to the concurrence processing and heavy traffic on customerdetails table, the insert request on the customerdetails table dies, this is I'm assuming.

If any one have ideas , please share your valuable point.

Thank u in advance


Viewing all articles
Browse latest Browse all 8428

Trending Articles