Author |
Topic |
kwikwisi
Constraint Violating Yak Guru
283 Posts |
Posted - 2008-04-14 : 22:51:20
|
hithis is my stored procedureCREATE PROCEDURE [dbo].[sp_AddAnsTemp] @id int, @proid int, @prodesc text, @proansw text,@proreso text,@chk intASinsert into TempAns(UserID,ProblemID,ProblemDescription,ProblemAnswer,ProblemResolution,Chk)values (@id, @proid, @prodesc, @proansw,@proreso,@chk)GOi want if problemid already exist in table,can't save this same problemidfor eg:problemid(3) exist for userid(2) and this userid try to save again for problemid(3),i want that he can't save |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-04-15 : 03:10:04
|
CREATE PROCEDURE [dbo].[sp_AddAnsTemp] @id int, @proid int, @prodesc text, @proansw text,@proreso text,@chk intASIf not exists(select * from TempAns where ProblemID=@proid)Begininsert into TempAns(UserID,ProblemID,ProblemDescription,ProblemAnswer,ProblemResolution,Chk)values (@id, @proid, @prodesc, @proansw,@proreso,@chk)EndGOMadhivananFailing to plan is Planning to fail |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-04-15 : 03:13:50
|
[code]CREATE PROCEDURE dbo.sp_AddAnsTemp( @id int, @proid int, @prodesc text, @proansw text, @proreso text, @chk int)ASSET NOCOUNT ONIF EXISTS (SELECT * FROM TempAns WHERE ProblemID = @ProID) UPDATE TempAns SET UserID = @id, ProblemDescription = @prodesc, ProblemAnswer = @proansw, ProblemResolution = @proreso, Chk = @chk WHERE ProblemID = @ProIDELSE INSERT TempAns ( UserID, ProblemID, ProblemDescription, ProblemAnswer, ProblemResolution, Chk ) VALUES ( @id, @proid, @prodesc, @proansw, @proreso, @chk )GO[/code] E 12°55'05.25"N 56°04'39.16" |
 |
|
kwikwisi
Constraint Violating Yak Guru
283 Posts |
Posted - 2008-04-15 : 04:46:59
|
for this procedure ,how to modify to get same target?CREATE PROCEDURE [dbo].[sp_ongoSubmit]@uid int ASinsert into sampleUserAns(UserID,ProblemID,ProblemDescription,ProblemAnswer,ProblemResolution,Chk)select UserID,ProblemID,ProblemDescription,ProblemAnswer,ProblemResolution,Chk from TempAnswhere UserID=@uidGO |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-04-15 : 04:54:42
|
You really need to study the suggestion we give to you!This last request is soo easy to accomplish. Just give it some time. E 12°55'05.25"N 56°04'39.16" |
 |
|
kwikwisi
Constraint Violating Yak Guru
283 Posts |
Posted - 2008-04-15 : 22:01:09
|
hi Peso,really thanks for your warm help and patient. I'm just a beginner in SQL and i don't know so much. |
 |
|
|
|
|