SQL Server数据类型从数字(7,3)更改为Varchar(20)

时间:2021-09-11 09:09:59

I have a field (dose_str) that needs to be changed from Numeric(7,3) to Varchar(20). I would like to know if there will be a need to change the query below (especially this portion SELECT (convert(varchar,cast(Prot_det.dose_str as float)) ) in the code of my application.

我有一个字段(dose_str)需要从Numeric(7,3)更改为Varchar(20)。我想知道是否需要更改下面的查询(特别是这部分SELECT(转换(varchar,cast(Prot_det.dose_str as float)))在我的应用程序的代码中。

myCommand.CommandText = "
  SELECT (convert(varchar,cast(Prot_det.dose_str as float)) + ' ' 
    + dose_unit + ' ' + dose_form_comment + ' ' + dose_mult) as Dose_str
  from 
    Prot_det, 
    dosage_form 
  where 
    Protocol_num = '" & lblProtocol.Text & "' and 
    nsc_num = " & lstNSC.SelectedValue & " and 
    prot_det.dose_form = dosage_form.dose_form"

1 个解决方案

#1


1  

After changing the datatype of the column, you will be able to change this:

更改列的数据类型后,您将能够更改此:

(convert(varchar,cast(Prot_det.dose_str as float)) 

to this:

(Prot_det.dose_str) 

And I would recommend that you do.

我会建议你这样做。

#1


1  

After changing the datatype of the column, you will be able to change this:

更改列的数据类型后,您将能够更改此:

(convert(varchar,cast(Prot_det.dose_str as float)) 

to this:

(Prot_det.dose_str) 

And I would recommend that you do.

我会建议你这样做。