When I import a csv file into sql, a numeric field is stored as varchar(50). How can I turn it into numeric(18,2)?
I don’t mean the function convert. I want to change the datatype while I import the file
What method/tool are you using to import the data?
If it's the Import/Export wizard, and you're creating a new table, you can change the default data type on the column in question in the column mapping section. (I might have the terminology wrong, I haven't used this wizard in a while)
If the table already exists, you would either ALTER TABLE...ALTER COLUMN to change the type, or if feasible, drop the table and create a new one and specify numeric(18,2) for that column.
I use the import wizard
Data source: float file
In the "Advanced" tab the "data type" section when I choose numerc[dt_numeric]
I get numeric(18,0) and I want numeric (18,2)
thank you
can you give me the data type of date in fomat "dd/mm/yyyy" ?
Dates can be displayed in different formats, but they are not stored with a format.
If you want to see the date formatted differently, you can either use CONVERT() with a style option such as 103 (CAST and CONVERT (Transact-SQL) - SQL Server | Microsoft Learn)
or you can use FORMAT() (FORMAT (Transact-SQL) - SQL Server | Microsoft Learn).
thank you.