0
我無法理解print
的工作原理,我沒有找到好的信息。 Stackoverflow問一些更多的細節,但我可以寫更多?SQL Server 2014 Management Studio - PRINT問題
declare @count int,
@experience varchar(30),
@date date,
@salary_old int,
@salary_new int,
@first_name varchar(30),
@second_name varchar(30),
@last_name varchar(30),
@i int=0
set @count = (select count(*) from cadre)
print ('-----------------------------------------------------------------------------------\n')
print ('id\tfirst_name\tsecond_name\tlast_name\told_salary\tnew_salary\texperience(years)\n')
WHILE @i < @count
BEGIN
set @date = (select date_of_start_work from cadre where [email protected])
set @first_name = rtrim((select first_name from cadre where [email protected]))
set @second_name = rtrim((select @second_name from cadre where [email protected]))
set @last_name = rtrim((select @last_name from cadre where [email protected]))
set @experience = rtrim(cast(((select year((SELECT GETDATE()))) - (select year(@date))) as varchar(30)))
set @salary_old = rtrim(cast((select salary from cadre where [email protected]) as varchar(30)))
set @salary_new = @salary_old*(@experience/100+1);
update cadre
set salary = @salary_new
where id_cadre = @i
print(rtrim(cast(@i as varchar(10)))+'\t'[email protected]_name+'\t'[email protected]_name+'\t'[email protected]_name+'\t'[email protected]_old+'\t'+rtrim(cast(@salary_new as varchar(10)))+'\t'[email protected]+N'\t')
set @[email protected]+1
END
print(@count)
錯誤:
Msg 245, Level 16, State 1, Line 28
Ошибка преобразования значения varchar "\t" в тип данных int.Error converting varchar "\ t" value to data type int.
能否請你** **翻譯的錯誤成英文? –
將varchar「\ t」值轉換爲數據類型int時出錯。 –