Click here to Skip to main content
16,004,564 members

Comments by Member 14800672 (Top 39 by date)

Member 14800672 28-Sep-21 16:32pm View    
Hi Richard,
The where statement was just to specify what to insert

But does this statement insert multiple records.. As you can see i need to copy 3 recrods from table1 in old db to new db
Member 14800672 10-Aug-21 6:58am View    
Hi Richard I updated the question in what i have tried section

I don't want to insert only the first two. i need to insert records in the table based on the number of items inside the string split (please note that @First and @Second will always contain equal counts, i mean if there is 5 values in @First, then there will be 5 different values in @Second)
Member 14800672 10-Aug-21 4:24am View    
Hi Anand,
i want to compare dateTime to dateTime and not date to DateTime
so i need the value before get< getutcdate() to be a dateTime and not a date
Member 14800672 10-May-21 9:58am View    
Hi,

I've tried this
select cast((select count(*) From MyTable
where Id =@Id and Flag= 1) as float) / cast((select count(*) From MyTable
where Id =@Id ) as float) *100

but now i'm getting value like
66.6666666666667
How can i make it 66.7?

and then how to decide this based on the value retrieved
if value <= 20 return bad
else if value >20 and <=40 return poor
else if value >40 and <=60 return good
else if value >60 and <=80 return good
else if value >80 and <=100 return perfect


I want to get 66.7% and good from my stored procedure
Member 14800672 10-Oct-20 7:47am View    
I did this

create PROCEDURE [dbo].[sp]
@Id1 int
,@BBId int
,@Text nvarchar(100) =''
AS
Begin
Begin transaction
declare @Id int

INSERT INTO table1
select @Text where @Text <> ''

SET @Id = SCOPE_IDENTITY()

INSERT INTO table2 (Id1, @Id)
select @Id1,@Id from table3
where table3.BBId = @BBId AND table3.Flag= 0 and
table3.Id1 = @Id1

IF(@@ROWCOUNT <= 0)
BEGIN

rollback transaction;
return
END
else
begin
UPDATE table3
SET Flag= 1
WHERE
table3.BBId = @BBID
AND table3.Id1 = @Id1
end
COMMIT TRANSACTION
END
Return 0

when i run it in SQL i get no errors, however when i call the stored procedure from .Net i get this error:
"Transaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statements. Previous count = 1, current count = 0.\r\nTransaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statements. Previous count = 1, current count = 0."