Answer the question
In order to leave comments, you need to log in
Error converting data type varchar to int. Line 0. Why is the procedure not processed?
Hello. Just started learning the basics of SQL. There was a question with transfer of values in procedure. Thanks in advance. Throws an error Error converting data type varchar to int. Line 0. Why is the procedure not processed? The procedure has already been created, so the problem is not in the alter.
Alter PROC inf
@nazvafacultetu varchar(50),
@grnum int,
@stn varchar(50),
@stln varchar(50),
@brth date,
@sumst int,
@yz date,
@stid int,
@sttid int,
@obychid int
AS
BEGIN
DECLARE @havemista INT;
DECLARE @nazvaf nvarchar(50);
DECLARE @chuslom INT;
select @nazvaf=nazva, @chuslom=Chuslo_mest, @havemista = Count(St_lname)
From Obych
INNER JOIN Facultet on (Facultet.FacultetID= Obych.FacultetID)
INNER JOIN student ON (Obych.StudentID=student.StudentID)
where @[email protected]
Group by Chuslo_mest, nazva
if @havemista<@chuslom
BEGIN
INSERT INTO Student values
(@stln, @stn,@brth)
INSERT INTO Obych values
( @grnum, @sumst,@yz,@stid,@nazvaf,@sttid)
END
else print 'Нету мест'+cast( @chuslom as varchar(2))
END
---
EXEC inf @nazvafacultetu='historical', @grnum=1,@stn='Anna', @stln='Maria', @brth='1998-12-08', @sumst=1200, @yz='2011-09-16', @stid=26, @sttid='woman' ;
Answer the question
In order to leave comments, you need to log in
The error is trying to tell you that it cannot convert varchar to int, look at where your text suddenly becomes numbers.
At the beginning you are asserting that @sttid is int and at the end you are trying to @sttid='woman'. Seems a bit illogical to me
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question