在將 varchar 值 轉換成數據類型 int 時失敗。


寫了個存儲過程是這樣的

create proc [dbo].[GetHotKeys]
(
  @top int,
  @where nvarchar(1000)
)
as
 declare @sqlStr nvarchar(1000)
 if @top<>''
   set @sqlStr='select top '+cast(@top as varchar(10))+' * from  hotkeys '+@where
 else
   set  @sqlStr='select * from  hotkeys '+@where

結果出現錯誤:在將 varchar 值 'select top ' 轉換成數據類型 int 時失敗。

解決辦法:set @sqlStr='select top '+cast(@top as varchar(10))+' * from  hotkeys '+@where

ok


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM