سلام.
sp خودتون رو بصورت زیر بنویسید و از پارامتر خروجی برای ارسال 1 یا 1- استفاده کنید :
ALTER PROCEDURE [dbo].[check]
@result int output
AS
if exists(select personnelcode
from table1
where table1.personnelcode not in (select personnelcode
from table2))
set @result = -1
else
set @result = 1
در سمت سی شارپ هم مقدار رو بصورت زیر دریافت کنید :
--------------------
connection = new SqlConnection(connectionstring);
SqlCommand command = new SqlCommand("check",connection);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("@result", SqlDbType.Int);
command.Parameters["@result"].Direction = ParameterDirection.Output;
connection.Open();
command.ExecuteNonQuery();
connection.Close();
int res = Convert.ToInt32(command.Parameters["@result"].Value);
if (res == -1)
MessageBox.Show("کد پرسنلی در جدول اول هست که در جدول دوم نیست");
else if (res == 0)
MessageBox.Show("تمامی کدهای پرسنلی موجود در جدول اول، در جدول دوم نیز وجود دارند");
موفق باشید.