SQL Convert from alphanumeric to numeric only - sql

Ok, I have a table I am querying for an outside project. The table has a field that is alphanumeric but the external project can only support numeric data. The outside project is needing my data as an Excel spreadsheet so I am trying to just export my query to Excel which I can do but I can't seem to figure out if there is a simple convert feature to do this for me. The originating table has the field as VARCHAR(10). I tried CAST and CONVERT but no go. This is SQL Server 2012.
Thanks.

Related

Change data type to date through a query in MS Access?

I have a .csv export of data where there's something "wrong" with how MS Access sees it when it's a linked data source. MS Access refuses to see them as date fields, and gives me a #NUM! error if I try to force it. However if I import it as a regular table or open it in MS Excel, the date field works fine. As such my date fields are stuck as short text fields in the linked .csv, which prevents me from sorting by a date range.
Is it possible to use a query to change the data type of a field? Short text field goes in one side, date/time (as recognized by MS Access) comes out the other?

Integration Services double to string

I'm using Integration Services to load data from an Excel file to SQL Server table. When I try to send a number stored as double (DT_R8) into a database column where data are stored as varchar(50) I find a queer rounding.
For example consider data in first row first column of above image. Original value is 31.35 but as a string it's stored as shown below
I already tried to use a Delivered Column transformation to cast to string before exporting to SQL, I also added a Round(x, 5) but I get the same result.
How can I solve this problem given that I can't change SQL column data type?
The only working solution was changing the input type from double (DT_R8) to currency [DT_CY]. It seems that the rounding performed on double (DT_R8) make its use difficult when parsing is somehow involved in the export process.

INT Inserted in SQL as NULL SSIS Package Excel to SQL

I have setup an SSIS package to take data from an excel file, and insert it into SQL.
The package takes the data from Excel, performs some Data Conversions, and then Inserts it into my SQL DB.
One of the columns in excel contains both text, and ints. Typically the values will be either: W2 or 1099.
In the data conversion data flow, this column is converted to: string[DT_STR], length: 50, Code Page: 1252 (ANSI - Latin I)
in SQL, the field it is going to is configured as a varchar(50).
For any row, where the column value in Excel is 1099, the data inserted into SQL, comes through as NULL.
I have no idea what could be causing this. I have similar conversions in other packages, that come through with no issues.
i have tried formatting the column in excel as text as well as re-creating the data conversion, with no luck.
Any suggestions of ways to get this to work properly appreciated. Please let me know if you need any additional information.
Is the data NULL in the Excel preview? You need to isolate whether this NULL is being provided by the Excel driver.
Anyway this sounds like the old IMEX=1 issue that has been around since forever.
http://microsoft-ssis.blogspot.com.au/2011/06/mixed-data-types-in-excel-column.html
Try adding IMEX=1 to your Excel connection string.

How can I split a string value in a SQL Server CE query?

I have a table containing a nvarchar column [AffectedNodes] that looks something like this when you take a peek at its contents (two variations shown):
"MID128; MID129; MID130"
"[1,3,2]; [3,1,2]"
We are working on a change which will move the AffectedNodes into its own table [AffectedNode] that has a nvarchar column [NodeId], which should store one of the nodes from the above string. I'm tasked with migrating the existing content to the new format.
As you can see the values are split using semi-column and a space.
To follow the database upgrade process they use in our project I have to write an SQL query in SQL Server CE. I'm wondering how I could do this in a neat way. Thanks!
SQL CE supports, CHARINDEX and SUBSTRING function, did you check that out or did you see any issue with them?

Date stored as a string in sql server when upsized from access 2007

When I upsize from Access2007 to SQL Server 2008, I have few issues...
1. text to nvarchar(255)
fields with text data type in Access are automatically converted to nvarchar(255)(I have unicode data) in sql server, but in reality the column-length is not that big so can I change the data type to nvarchar(55) or varchar(100)? Will there be any problem?
2. Date stored as text
Some tables throwed an error when tried to upsize because of the date column(mm/dd/yyyy), what I did is I changed the date/time column data type to text datatype in access, then the upsizing was successful, it converted to nvarchar(255) in sql server. I have converted nvarchar data type to date data type in sql server, but that does not show me a calendar symbol in access front-end. How to get a calendar symbol in the date field in my access front end?
I have tried the solution given in this link, but it did not work... Please give me some suggestions
text in sql server is deprecated, use nvarchar if you need to store unicode (multi lang support). Otherwise you can use varchar.