If we will execute following sql
query in sql server:
DECLARE @Today AS DATETIME = GETDATE()
DECLARE
@Second AS
INTEGER
SET @Second = @Today
SET @Second = CAST(@Today AS INT)
We will get error message :
Disallowed
implicit conversion from data type to data type, table '', column ''. Use the
CONVERT function to run this query.
Cause: Implicit conversion of
datetime data type to int, small int, bit etc. is not possible. We have to explicitly
type cast in int.
Solution:
SET @Second = CAST(@Today AS INT)
Or
SET @Second = CONVERT(INT,@Today)
No comments:
Post a Comment