PDA

View Full Version : سوال: مشکل در اجرای Sp



matsa1361
پنج شنبه 12 دی 1387, 12:18 عصر
در هنگام اجرای SP ذیل :
IF EXISTS (SELECT name
FROM sysobjects
WHERE name = 'sp_scoring'
AND type = 'P')
DROP PROCEDURE sp_scoring

GO

CREATE PROCEDURE sp_scoring @inmerchant char(10) ='sh',
@inyear int(4)=1387,
@inseason int(4)=1

as
Declare @merchant char(8)
Declare @season char(8)

select @merchant= merchantname
from merchant
where merchant.code=@inmerchant
select @season= ses
from season
where season.code=@inseason
----------------------------------------------------------------------------------
Insert into result
Select top 3 * from information1
Where finalscore>100 and season=@season and year=@inyear and merchant=@merchant
Select top 5 * from information1
Where finalscore>50 and finalscore<100 and season=@season and year=@inyear and merchant=@merchant
Select top 7 * from information1
Where finalscore>100 and finalscore<50 and season=@season and year=@inyear and merchant=@merchant
----------------------------------------------------------------------------------
update result
set gift='کارت 100000'
where finalscore>100
update result
set gift ='کارت 50000'
where finalscore>50 and finalscore<100
update result
set gift ='کارت 30000'
where finalscore<50 and finalscore>40

-----------------------------------------------------------------------------------
با خطای :
Server: Msg 2716, Level 16, State 1, Procedure sp_scoring, Line 0
Column or parameter #2: Cannot specify a column width on data type int.
Server: Msg 2716, Level 16, State 1, Procedure sp_scoring, Line 0
Column or parameter #3: Cannot specify a column width on data type int.
Parameter '@inyear' has an invalid data type.
Parameter '@inseason' has an invalid data type.
مواجه می شویم ، لطفاً مرا راهنمایی کنید.با تشکر

AminSobati
پنج شنبه 12 دی 1387, 13:15 عصر
دوست عزیزم،
INT طولش ثابته و نباید مثل VARCHAR بهش طول بدین

matsa1361
شنبه 14 دی 1387, 08:28 صبح
با تشکر از راهنمایی شما.
خیلی ممنون