Data is like below in CVS file, Loading to SQL server using openrowset. Number rows are converted fine but number with text(xy1468028906,ab1468028906) rows converted to null.
1468028906
1783084622
xy1468028906
AB1783084622
Column data type in the tabel is nvarchar(max)
So, the data is loaded into table like below
1468028906
1783084622
null
null
How can we load data properly, any suggest.
Related
I have a linked server to Oracle database in SQL server and retrieve data to local SQL server database every day by scheduling, the problem is: one of the Oracle database column has holding number with 18 fixed digits which type is NUMBER(18) and when I am trying converting that column to numeric(18,0) or numeric(38,0) and so on, the data converted but for many of them, last digit is different with source data, for example:
data in Oracle database(source): 100002345678912345
data in SQL database (destination): 100002345678912348
Thanks to #Jeroen Mostert.
I used DBCC TRACEON (7314) before INSERT INTO and my data is changed to DOUBLE type, after that to solve the problem I used SELECT CAST(COLUMN_NAME AS numeric(18,0))
for example:
My Real Data:100002345678912345
My Data (wrong data): 100002345678912348
My Data after using DBCC TRACEON (7314):
100002345678912345.0000000000
My Data after using SELECT CAST(COLUMN_NAME AS NUMERIC(18,0)):
100002345678912345
I have a XML data column in a SQL Server table. There are more than 5000 elements in the XML. I intended to make a table out of that XML formatted column.
As far as I'm aware, SQL has a limitation that a table can only have 1024 columns. How will I flatten the file so that it may be used for reporting?
I have dates in the format 01jan2020 (without a space or any separator) and need to convert this to a date type in SQL Server 2016 Management Studio.
The data was loaded from a .CSV file into a table (call it TestData, column is Fill_Date).
To join on a separate table to pull back data for another process, I need the TestData column Fill_Date to be in the correct format (MM-DD-YYYY) for my query to run correctly.
Fill_Date is currently in table TestData as datatype varchar(50).
I want to either see if it is possible to convert it with TestData table or directly insert the result into a 2nd table that is formatted.
Thanks (NEWB)
I ended up solving by converting the data while dropping into a temp table, deleting old value, and then inserting from that table back into the TestData table.
CONVERT(VARCHAR,CONVERT(date,[fill_date]),101) AS fill_date
I am running an insert statement to populate records into a table using SQL Server 2012. In table 1 that has all the records, the datatype is VARCHAR(5000), and I have done a max(len) to determine that the maximum length of data it contains is about 3000.
In table 2 that the records should go into, the datatype for the field is VARCHAR(5000), which mirrors what's in Table 1.
I am getting the dreaded binary or string data would be truncated message, but my destination table field is large enough to store this data.
When I remove this field from the insert statement, the insert statement works fine and my data moves from Table 1 to Table 2 as expected, but including the field causes this error.
Has anyone come across this peculiar case before? Is it possible that the string field has some sort of weird characters in it that could be causing this error.
Thanks
I'm using SQL Server 2008 with SQL Server Management Studio 10 to create tables and views.
My problem is I want to create a view from several tables with a lots of columns but I'm limited by the size of the rows (8060 bytes per row).
Some columns have varchar(255) types, and according to the documentation this column cannot be out-of-row and to make it work I need to convert it to the varchar(MAX) value.
See this thread: Strategies for bypassing the 8,060 byte limit on Row Length
But I can't modify the original types.
So, how can I convert or cast with my view (if possible with the SSMS creation tool) the original types to varchar(MAX) values for example?
EDIT : Full statement
SELECT dbo.V_NUM1.rownum, dbo.V_NUM1.id, dbo.V_NUM1.PAR_N, CONVERT(nchar(MAX), dbo.V_NUM1.PAR_Objet) AS PAR_Objet, ...... , dbo.V_NUM2.PAR_gestion_site_theme, dbo.NUM3.COM_RCD_PAR_N
FROM dbo.V_NUM1
FULL OUTER JOIN dbo.V_NUM2 ON dbo.V_NUM1.PAR_ID = dbo.V_NUM2.PAR_ID
FULL OUTER JOIN dbo.V_NUM3 ON dbo.V_NUM1.PAR_ID = dbo.V_NUM3.COM_RCD_PAR_N