When pass a value to integer datatype variable in the form of string value then that accept it because after accept first that value is implicitly CAST to an integer then the value is assigning to the parameter.
Ex- If we pass an integer value as ' 145 ' to integer type parameter then it implicitly CAST to an integer type value successfully in 145 then it assigned to the parameter of stored procedure then the statement is work file.
I have create a Stored Procedure with two parameters,
We pass Value to parameter of above stored procedure like-
EXEC sp_Demo @ID=145, @Name=' Radhe Krishna ' ;
The above procedure work file.
If we pass the value ' 145' instead of 145 to @ID parameter and ' Radhe Krishna ' to @Name parameter then also that procedure execute fine because before accepting the value to parameter that value will CAST first to the parameters datatype then assign to the parameters so stored procedure work fine and execute.
Note - CAST is function to convert one datatype value in other datatype value. CONVERT() is also used for same purpose.
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Passing a number in string format to an integer variable in a stored procedure :
When pass a value to integer datatype variable in the form of string value then that accept it because after accept first that value is implicitly CAST to an integer then the value is assigning to the parameter.
Ex- If we pass an integer value as ' 145 ' to integer type parameter then it implicitly CAST to an integer type value successfully in 145 then it assigned to the parameter of stored procedure then the statement is work file.
I have create a Stored Procedure with two parameters,
We pass Value to parameter of above stored procedure like-
The above procedure work file.
If we pass the value ' 145' instead of 145 to @ID parameter and ' Radhe Krishna ' to @Name parameter then also that procedure execute fine because before accepting the value to parameter that value will CAST first to the parameters datatype then assign to the parameters so stored procedure work fine and execute.
Note - CAST is function to convert one datatype value in other datatype value. CONVERT() is also used for same purpose.