There has to be a way to store a datatype in a variable and then use that variable in a conversion/cast.
I tried to do it this way but i keep getting this error:
"Server: Msg 170, Level 15, State 1, Line 2
Line 2: Incorrect syntax near '@DATATYPE'."
DECLARE @DATATYPE VARCHAR(25)
SELECT @DATATYPE = 'MONEY'
UPDATE Table1
SET AMOUNT = CAST('5000'AS @DATATYPE)
WHERE Table_ID = 100
Does anyone have any suggestions?
Thanks so much.
I tried to do it this way but i keep getting this error:
"Server: Msg 170, Level 15, State 1, Line 2
Line 2: Incorrect syntax near '@DATATYPE'."
DECLARE @DATATYPE VARCHAR(25)
SELECT @DATATYPE = 'MONEY'
UPDATE Table1
SET AMOUNT = CAST('5000'AS @DATATYPE)
WHERE Table_ID = 100
Does anyone have any suggestions?
Thanks so much.