While using an insert query for a certain table, can I used a select statement to know whether there's an already existing value in the stored procedure using a return value where insert occurs? Or do I need to separate a procedure? I don't know much of return values.
AngelicOne
4
Posting Whiz
Recommended Answers
Jump to PostYes! you can use select statement.
Stored procedure to insert a record (Table dept (deptno, deptname))
CREATE PROCEDURE add_dept @deptno int, @deptname varchar(30) AS declare @count int select @count=count(*) from dept where deptno=@deptno if @count=0 begin insert into dept (deptno,deptname) values (@deptno,@deptname) end RETURN
C# code …
Jump to PostYou didn't put a sqlparameter direction?
The default is Input.
All 6 Replies
kvprajapati
1,826
Posting Genius
Team Colleague
AngelicOne
4
Posting Whiz
kvprajapati
1,826
Posting Genius
Team Colleague
AngelicOne
4
Posting Whiz
kvprajapati
1,826
Posting Genius
Team Colleague
AngelicOne
4
Posting Whiz
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.