https://docs.microsoft.com/en-us/sql/t-sql/functions/cast-and-convert-transact-sql
Conversion failed when converting the varchar value ' ' to data type int.
存储过程,有一个传递进来的参数是int类型的
在存储过程中,进行字符串拼接的话,需要把int手动转换成nvrchar
可以使用Cast或者Convert函数
SELECT 9.5 AS Original, CAST(9.5 AS INT) AS [int], CAST(9.5 AS DECIMAL(6, 4)) AS [decimal]; SELECT 9.5 AS Original, CONVERT(INT, 9.5) AS [int], CONVERT(DECIMAL(6, 4), 9.5) AS [decimal];
Original int decimal
9.5 9 9.5000
Convert String to DateTime
https://stackoverflow.com/questions/1135746/sql-server-convert-string-to-datetime
SELECT CONVERT(datetime, '2018/01/04 11:22:01', 120)
第三个参数,120是style,ODBC canonical,yyyy-mm-dd hh:mi:ss(24h) 。
SELECT CONVERT(datetime, '2018-01-04 11:22:01', 110)
第三个参数,110是style,USA,10 = mm-dd-yy,110 = mm-dd-yyyy