-2

Can the datatype of a field be changed to bigint from float ??

Create a new column that's an integer:

ALTER TABLE tabl ADD newCol int;

Select the data from the old column into the new one:

UPDATE tabl SET newCol = CAST(TEL2 AS int) FROM tabl ;

P.S: I am using MS SQL Server

i try to us this in c# but it didn't get any result

  string sqlCommand = "SELECT * FROM tabl WHERE CONCAT([TEL1], [TEL2],[TEL3], [TEL4],[TEL5], [TEL6],[TEL7], [TEL8],[TEL9]) LIKE '%" + txtBoxSearch.Text + "%'";

I store telephone numbers as float and try find it by the c# code and didn't get any result so im trying to convert the column or correct the c# code

ahmed_eltot93
  • 118
  • 16

2 Answers2

2

Try using the STR() function:

SELECT STR(your_float_field, 25, 0)

This would return your float value as a string. Note: This function pads on the left with spaces. If this is a problem, combine with LTRIM function:

SELECT LTRIM(STR(your_float_field, 25, 0))
Rahul Sharma
  • 7,768
  • 2
  • 28
  • 54
-1

No,because float contain decimals And bigint contain only integer. But bigint can be converted into Float as float contain both part -integer and decimals. If your float value contains .00 as the decimal value then it can be changed into bigint. Thanks. If you want more about datatype conversion.then please comment. Thanks again.