Converting Date Field From Informix To SQL Nvarchar
Apr 13, 2004
I copying data from our Informix 7.2 database into SQL Server 2K using DTS but hitting errors during the process. There appears to be date data within Informix that will not convert properly when moving into SQL. Since the error is appearing at the 1.5million (approx.) record. I figured on changing from datetime to nvarchar. Works like a charm! :-)
My new problem is converting it back to datetime so I can query against the date without having to create scripts to parse the field.
The data in SQL currently looks like this -> 2000-11-29 (nvarchar(50))
I would like to have it -> 11/29/00 (datetime)
Any help is greatly appreciated!
JT
The goodness we share is rewarded twice!
View 10 Replies
ADVERTISEMENT
Oct 17, 2007
I am trying to drag data from Informix to Sql Server. When I kick off the package
using an OLE DB Source and a SQL Server Destination, I get DT_DBDATE to DT_DBTIMESTAMP
errors on two fields from Informix which are date data ....no timestamp part
I tried a couple of things:
Created a view of the Informix table where I cast the date fields as datetime year to fraction(5), which failed.
Altered the view to convert the date fields to char(10) with the hopes that SQL Server would implicitly cast them
as datetime but it failed.
What options do I have that will work?
View 1 Replies
View Related
Apr 29, 2015
I am getting the above error when trying to add a dataset to my report. Here is my stored procedure below.
USE [HSIU_TEST]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [ssrs].[spKEMHWaitTimeCaseList]
[Code] .....
View 5 Replies
View Related
Feb 4, 2015
I am trying to convert a decimal date value to a date value that I can use in formulas but am having a lot of trouble.My date value currently shows in decimal format YYYYMMDD. I want to convert this to a date so I can then find the number of days between two dates.I have tried convert (datetime, convert(varchar(8),left(qhstdt,8))) with qhstdt as my decimal date field but I receive the error message below:
Error: SQL0204 - CONVERT in *LIBL type *N not found.
I have also tried converting it using (year(QHSTDT)*10000+100*month(QHSTDT)+ day(QHSTDT))) but when I convert the dates using this formula, I can get an incorrect number of days when I try to subtract one from the other.What formula can I use to convert my YYYYMMDD field to a format that will allow me to compare number of days between two dates?
View 2 Replies
View Related
Dec 28, 2004
I have a 6 char field which has to be converted to a datetime. I thought I had it solved when I did this
convert(datetime,(left(dob,2)+'-'+substring(dob,3,2)+'-'+right(dob,2)))
Problem is with a date value of 081649
I get 08/16/2049 instead of 1949, where did I goof
View 1 Replies
View Related
Mar 30, 2007
How can I create a field in a view that takes a date field andconverts it to a month?For instance, if I have a field called "CreatedOn" with a date of'2/22/2007', how can I create another field called "Month" that willsay "February"? Is there a built-in SQL function that does this (likeusing CONVERT) or do I need to write my own?Thanks!Lisa
View 1 Replies
View Related
Aug 28, 2015
I have a very strange situation. I've increased the size of an NVARCHAR field from 8 to 9 in a database table. The format of the data that I enter will either be an 8 character field (123456-8) or a 9 character field (1234567-9). The '-' is critical.
It used to only accept the 8 character version, but after increasing the field size, if I try to insert the 9 character field version, it gets truncated after the '-', as though it's still only allowing 8 characters. But that only occurs when I include the '-' or other such characters like '#'. If I try to insert 1234567a9, it works. The following explains the outcomes:
Inserted Value -> Result in table
123456-8 -> 123456-8 *Correct
1234567-9 -> 1234567- *Wrong
123456789 -> 123456789 *Correct
1234567#9 -> 1234567# *Wrong
1234567a9 -> 1234567a9 *Correct
Why is it that characters such as '-' and '#' are truncating the value, but only if the string is 9 chars long?
I'm currently using a direct t-sql insert statement in SQLExpress. The field is a simple NVARCHAR(9) field.
View 3 Replies
View Related
Oct 28, 2004
Hello all,
I'm trying to convert a nvarchar datatype to int
(ie:1234-56-78 to 12345678) . These values are primary keys in two tables. Both these tables have 3500 rows of this key type. I want to convert this to a int so I can make it a AutoNumber primary key so I can increment it. Is this possible? If so, how do I do it. Do I need to delete the dashes first some how? I fairly new to database adminstration, so any guidance will be greatly appreciated.
Thank You
View 2 Replies
View Related
Jul 21, 2006
Columns from database have values like 1,5 etc and I'm getting the error: Syntax error converting the nvarchar value '1,5' to a column of data type int. when trying to convert from nvarchar to int:
SELECT CONVERT(int, MyNVarChar_column) FROM MyTable
What I'm doing wrong? Thanks a lot
View 1 Replies
View Related
Jul 20, 2005
For a SQL statement in an Alias column I am am combing severalcolumns.But I am having problems with one column as it is a smallint.I get this errorSyntax error converting the nvarchar value to a column of data typesmallintMy Sql statement "Select Stilngcol1 + stringcol2 + intcol1 + stringcol3 As NewColNamefrom Table1I was wondering is there anyway to format/convert the smallint tonvarchar, without changing the database.
View 3 Replies
View Related
Jan 17, 2008
i have some fields in SQL Server table as nvarchar(50) and the user actually enters date (example : 02/05/07) now they want those fields to be converted to datetime or small datetime field.
How do i achieve it without losing data?
Thanks
bhu
View 1 Replies
View Related
Jan 15, 2004
I am trying to read an Informix 9.3 blob field into a TSQL (SQL Server Stored Procedure) and the data type conversion is not supported thru the MS ODBC Driver installed with Win2000/SQL2000. Does anyone know of another method to retrieve this data, or of a vendor that provides an ODBC driver that supports the Informix blob data type. Thanks!
View 1 Replies
View Related
Oct 18, 2006
I have a field in nvarchar type. It contains data like 0, :23, 1:57, ... all in minutes and seconds. Now, I need to convert it to MM:SS using query and get the Average of this column. How can I do it? I have tried Avg(Convert(nvarchar(20), [Calling Time], 108)) .. but I got error : The average aggregate operation cannot take a nvarchar data type as an argument.Help!!!! :(
View 1 Replies
View Related
May 15, 2005
Hi there,I have a table named Action. This table has a column InPrice with datatypenvarchar(12). I want to change its datatype from nvarchar(12) to money. Ibrowsed through the values and removed any dots. Th column now has onlynumeric values (and commas for decimal values such as 105,8). When I try tochange the datatype from nvarchar to money, following mesage is displayed:ADO error: Cannot convert a char value to money. The char value hasincorrect syntax.How can I solve this problem? I cannot figure out which values are causingthis error.Thanks in advance,Burak
View 4 Replies
View Related
May 9, 2001
I need help converting an nvarchar value to int. I receive a SQL error when running the following query...
"SELECT DISTINCT [Time Cards].TimeCardID, [Time Cards].Status, [Time Cards].Verification, [Time Card Hours].[Date Worked], [Time Card Hours].[Billable Hours], [Time Card Hours].[Billing Rate], [Time Card Hours].[Overtime Hours], [Time Card Hours].[Overtime Rate], Employees.FirstName, Employees.LastName, [Function].[Function], [Time Card Hours].[Invoiced Hours], [Time Card Hours].[Invoiced Overtime], [Time Cards].[30 Day Grace]
FROM [Function] INNER JOIN (Employees INNER JOIN ([Time Cards] INNER JOIN [Time Card Hours] ON [Time Cards].TimeCardID = [Time Card Hours].[Time Card ID]) ON Employees.EmployeeID = [Time Cards].EmployeeID) ON [Function].FunctionID = Employees.FunctionID
WHERE ((([Time Cards].[30 Day Grace])=-1));"
[Time Card Hours - nvarchar, Time Cards - int]
View 2 Replies
View Related
Mar 21, 2006
I have a problem converting a float filed into nvarchar.
select cast(sold as varchar(50))
where sold=431597.15 results in 431597 and is ignoring always my decimals.
Do you have any idea how to fix this?
ty
View 1 Replies
View Related
Jun 23, 2008
Hi all
I want to pass a list of nvarchar characters to my procedure, then import them into a temporary table as numeric(5,2) numbers.
The code below does this but the values are corrupted (e.g. 76.25 becomes 7 in the table).
Can anyone please tell me what I'm doing wrong? Thank you!
declare @separator_position int
declare @array_value nvarchar
declare @separator char
DECLARE @numberList NVARCHAR(MAX)
SET @numberList = '23|76.25|100.36|45.54|87.14|74.25|8|98|'
SET @separator = '|'
SET @separator_position = NULL
SET @array_value = NULL
DECLARE @myTable TABLE(ID INT IDENTITY(1,1), compLevel NUMERIC(5,2))
WHILE patindex('%' + @separator + '%', @numberList) <> 0
BEGIN
SELECT @separator_position = patindex('%' + @separator + '%' , @numberList)
SELECT @array_value = LEFT(@numberList, @separator_position - 1)
INSERT INTO @myTable (compLevel) VALUES (CONVERT(NUMERIC(5,2), @array_value))
SELECT @numberList = stuff(@numberList, 1, @separator_position, '')
END
SELECT * FROM @myTable
View 4 Replies
View Related
Aug 13, 2014
i have the following code:
SELECT Quantity
FROM dbo.BNYForwardsTaxLotsForwards
WHERE investmentType ='Forward Cash'
and Quantity < 0
And I get the following error Msg 245, Level 16, State 1, Line 1..Conversion failed when converting the nvarchar value '-12213949.9' to data type int.
View 2 Replies
View Related
Mar 10, 2008
Hi,
I used to work with Sql 2000 and I could easily import a text file into my database and then convert the fields (all nvarchar) to appropriate data types. However, this procedure does not work with Sql 2005.
After I import a text file to Sql 2005 and when I convert nvarchar to numeric, I get "Error converting data type nvarchar to numeric".
Could you please let me know how can I fix this issue. Thanks in advance for your reply.
View 12 Replies
View Related
Mar 11, 2008
One of my clients decided to put letters into their customers' account numbers. They have a numbering scheme where all temporary accounts have a letter in the account OR are numbered greater than 33000, and all permanent accounts are all digits and less than or equal to 33000. all primary accounts have a NumberSuffix of 000.
Now i am tasked with retrieving all primary, non-temp accounts. I cannot simply do WHERE Number <= 33000 because when it gets to an account containing a letter like "00A01", it craps out and says "Conversion failed when converting the nvarchar value '00A01' to data type int."
So decided to run a filtering query first to filter out all accounts with letters, and then from that dataset select all accounts <=33000.
WITH members (FirstName, LastName, Number, NumberSuffix) AS
(
SELECT
dbo.Entity.FirstName,
dbo.Entity.LastName,
dbo.Entity.Number,
dbo.Entity.NumberSuffix
FROM
dbo.Entity
WHERE
NumberSuffix = 000 AND
Number NOT LIKE '%A%' AND
Number NOT LIKE '%B%' AND
Number NOT LIKE '%C%' AND
Number NOT LIKE '%D%' AND
Number NOT LIKE '%E%' AND
Number NOT LIKE '%F%' AND
Number NOT LIKE '%G%' AND
Number NOT LIKE '%H%' AND
Number NOT LIKE '%I%' AND
Number NOT LIKE '%J%'
)
SELECT *
FROM
members
WHERE
Number <= 33000
ORDER BY
Number
when i do this, i get the same error for some reason. Yet when i execute this at the end instead:
SELECT *
FROM
members
WHERE
Number LIKE '%A%'
ORDER BY
Number
i get an empty set (meaning it actually does get filtered).
but somehow it still able to participate in a range comparison?
WHY??
thanks,
Leon
View 10 Replies
View Related
Jan 14, 2008
Okay, I have the following store procedure and I kept getting an error.
Code Block
ALTER PROCEDURE [dbo].[Search]
-- Add the parameters for the stored procedure here
@schoolID int = NULL,
@scholarship varchar(250) = NULL,
@major varchar(250) = NULL,
@requirement varchar(250) = NULL,
@debug bit = 0
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
Declare @SQL as Varchar(4000);
Declare @Params as Varchar(3000);
Set @SQL = N'SELECT * FROM [scholarship] WHERE [sectionID] = ' + @schoolID;
Set @Params = N'@scholarship VARCHAR(250),@major VARCHAR(250),@requirement VARCHAR(250)'
If @scholarship IS NOT NULL
Set @SQL = @SQL + N' AND [scholarship].[schlrName] LIKE + ''%'' + @scholarship + ''%'''
If @major IS NOT NULL
Set @SQL = @SQL + N' AND [scholarship].[Specification] LIKE + ''%'' + @last + ''%'''
If @requirement IS NOT NULL
Set @SQL = @SQL + N' AND ([scholarship].[reqr1] LIKE + ''%'' + @requirement + ''%'''
If @requirement IS NOT NULL
Set @SQL = @SQL + N' OR [scholarship].[reqr2] LIKE + ''%'' + @requirement + ''%'''
If @requirement IS NOT NULL
Set @SQL = @SQL + N' OR [scholarship].[reqr3] LIKE + ''%'' + @requirement + ''%'''
If @requirement IS NOT NULL
Set @SQL = @SQL + N' OR [scholarship].[reqr4] LIKE + ''%'' + @requirement + ''%'''
If @requirement IS NOT NULL
Set @SQL = @SQL + N' OR [scholarship].[reqr5] LIKE + ''%'' + @requirement + ''%'')'
If @debug = 1
PRINT @SQL
Exec sp_executesql @SQL, @Params, @scholarship, @major, @requirement
END
And I kept getting this error:
Msg 245, Level 16, State 1, Procedure Search, Line 28
Conversion failed when converting the nvarchar value 'SELECT * FROM [scholarship] WHERE [sectionID] = ' to data type int.
Any help is much appreciated.
View 7 Replies
View Related
Jul 23, 2005
Hello. I have an Informix SQL statement that I need to run in MS SQLServer. When I try to execute it I get the following error message fromQuery Analyzer:Server: Msg 195, Level 15, State 10, Line 4'date' is not a recognized function name.Can anyone help me convert this informix sql statement into and MS SqlStatement? Here is the query I have:selecta.comp_code,a.comp_date,case when date(date(date(comp_date - day(comp_date) +1) - 2 unitsmonth) - 1 units day) < b.inception_date then b.inception_dateelse date(date(date(comp_date - day(comp_date) +1) - 2 units month) - 1units day)end prior_date,a.net_return,a.net_uv,a.gross_return,a.gross_uv,a.estimated_flagfrom composite_perf a, composite_detail bwhere(month(a.comp_date) in (3,6,9,12) or a.comp_date = b.inception_date)and a.comp_code = 'AEU'and a.comp_code = b.comp_codeinto #tmp_composite_dataThanks in advance.
View 4 Replies
View Related
Mar 27, 2008
Hi i keep getting this error when i search based on Team name (dropdownlist) or coach name(textbox). However it works when i make the search based on the region id(dropdownlist) here is my stored procedure;ALTER PROCEDURE [dbo].[stream_FindTeam]
-- Add the parameters for the stored procedure here
@coachName varchar(100),
@TeamName varchar(100),@regionID INT
AS
SELECT TeamID, coachName FROM Teams WHERE coachName LIKE @coachName OR TeamName= @TeamNameOR regionID = @regionID;
Here is my code;SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["streamConnectionString"].ConnectionString);
conn.Open();SqlCommand command = new SqlCommand("stream_FindTeam", conn);
command.CommandType = CommandType.StoredProcedure;command.Parameters.AddWithValue("@coachName", coachName.Text);
command.Parameters.AddWithValue("@TeamName", TeamList.SelectedValue);command.Parameters.AddWithValue("@regionID", Region.SelectedValue);SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);
DataList1.DataSource = reader;
DataList1.DataBind();
conn.Close();
View 13 Replies
View Related
May 11, 2000
I am trying to do some amount calculations.
The amount was declared as nvarchar data type.
I did the following coding. I want to get 2 places right of decimal
but am getting only one place right of decimal.
SELECT
(CAST(EQ_TotQuoteAmnt AS Float(7,2)) -
CAST(EQ_InsFee AS Float(7,2)) - 150) as Inforce_Premium
FROM Quoted
Can someone please help me with the syntax?
Thanks in advance.
M. Khan
View 1 Replies
View Related
Apr 8, 2004
HI,
I HAVE BEEN TRYING TO TRANSFORM AN OLD TABLE TO A NEW FORMAT AND CHANGE SOME OF THE DATATYPE FORMATS USED IN THE OLD ONE.
OUT OF WHICH ONE IS A COLUMN CALLED AS FORM_RECEIVE_DATE WHICH HAS NVARCHAR(41) AS DATATYPE IN THE OLD TABLE CREATED BY A PREVIOUS DBA (DON'T KNOW wHY?)
wHILE CONVERTING IT INTO DATATYPE DATETIME , I AM GETTING THIS ERROR :- "Arithmetic overflow error converting expression to data type datetime." i DON'T KNOW WHY
hERE ARE FEW EXAMPLES OF THE DATA CONTAINED IN THE PREVIOUS TABLE :-
05082003
05062003
05142003
COULD YOU PLS TELL ME A WAY TO SOLVE THIS ?
View 4 Replies
View Related
Jul 24, 2015
I have a column name DateofRecord and it is nvarchar type..all the values in this column are like this
"04/24/2013'
"05/01/2014"...etc...
My requirement is to convert this column into Datetime ?
I tried so many ways using cast and convert functions like cast(dateofrecord,datetime) or like convert(datetime,replace(DateofRecord,'"','''')) ..it didnt worked..
View 9 Replies
View Related
Feb 28, 2008
Hi,
I get "Error converting data type nvarchar to int." It is some kind of SQL exception. This is the code in my application.
SqlConnection sqlConnection1 = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
SqlCommand cmd = new SqlCommand();
Object start;
string activityID = Session["activitygroupID"].ToString();
cmd.Parameters.AddWithValue("@ActivityGroupID", activityID);
cmd.CommandText = "get_startdate";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = sqlConnection1;
sqlConnection1.Open();
SqlDataReader reader = cmd.ExecuteReader(); //The code stops here!!!
start = reader["StartDate"];
sqlConnection1.Close();
The stored procedure on the SQL-server looks like so. StartDate is of DateTime type.
ALTER PROCEDURE [dbo].[get_startdate]
-- Add the parameters for the stored procedure here
@ActivityGroupID int
AS
BEGIN
SELECT StartDate
FROM dbo.CurrentGroup
WHERE ActivityGroupID = @ActivityGroupID
END
I appreciate any help!
View 4 Replies
View Related
Oct 7, 2015
I am new to SQL and trying my hand at what I thought would be a simple query to bring back the loan products that are not HMDA reportable - hence the NOT IN and I get an error message after adding the NOT IN...I have read a lot of responses to the issue of an error message of 'Conversion failed when converting the nvarchar value' to try and solve the error - and have had no luck. Before I throw my laptop out the window..Here is the error message along with what I thought was a simple query; Conversion failed when converting the nvarchar value '80/10/10' to data type int.Here is the query;
SELECT
P.ProductID,
P.Name,
PC.Name AS [Product Group],
LP.Name AS [Loan Purpose],
CASE WHEN LP.IsHMDAReportableFL = 0 THEN 'No' ELSE 'Yes' END AS [HMDA Reportable],
[code]...
View 5 Replies
View Related
Apr 1, 2008
Exception in one of the stored procs:
Conversion failed when converting the nvarchar value to datatype int. After moving database from 2000 to 2005.
Using backup and restore.
Note I had the same issue after restoring the production database on my local server SQL2000->SQL2000.
The problem was solved by restoring master and msdb from the production. But I can't do this on the SQL2005.
This is not a collation issue as I have ensured collation is the same on all databases including the system ones.
The database in question makes extensive use of user defined data types (Which I have recreated on the destination server).
Can anyone please help?
Raf
View 9 Replies
View Related
Feb 25, 2008
I getting the above error can someone please help me solve it, here is the code:
public void InsertHost() { // TODO // - Call stored procedure to write to a log file writeToLog using (SqlConnection cn = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"])) { SqlCommand cmd = new SqlCommand("writeToLog", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@pAction", "action"); cmd.Parameters.AddWithValue("@pHostName", "Hostname"); cmd.Parameters.AddWithValue("@pUserNUm", "requestorID"); cn.Open(); cmd.ExecuteNonQuery(); } }
Here is the storedprocedure:
ALTER PROCEDURE dbo.writeToLog(@pAction varchar(10), @pUserNUm bigint, @pHostName varchar(25))AS INSERT INTO dbo.hostNameLog (action, requestorID, HostName)VALUES (@pAction, @pUserNUm, @pHostName)
Here is the table:
HostName - varchar, action - varchar, requestorID - bigint
I can't seem to find the error.
View 7 Replies
View Related
Jun 1, 2008
i am getting this error when passing multiple checkbox values to next page..
Error is Conversion failed when converting the nvarchar value '3,4' to data type int.
my code is below
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:mobiletimesConnectionString %>"
SelectCommand = "SELECT * FROM [device] WHERE [dev_id] IN (@chk1)">
<SelectParameters>
<asp:FormParameter FormField="chk1" Name="chk1" />
</SelectParameters>
</asp:SqlDataSource><asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1"
BackColor="White" BorderColor="#CC9966" BorderStyle="None" BorderWidth="1px"
CellPadding="4" GridLines="Both">
<FooterStyle BackColor="#FFFFCC" ForeColor="#330099" />
<ItemStyle BackColor="White" ForeColor="#330099" />
<SelectedItemStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#663399" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="#FFFFCC" />
<ItemTemplate><div class="overviewpdamain" >
<div class="overviewpdadevice">
<center>
<b><%#Eval("dev_name")%></b><br />
<b>
</b>
</center></div>
</div></ItemTemplate>
</asp:DataList>
View 6 Replies
View Related
Mar 23, 2006
Hi
I have an insert stored procedure with a parameter @eventDate date type date time. I have written a web form that takes the textbox.text value and assigns to the @eventDate parameter using a querystring. Howevr when I run the application I get a SQL Exception error converting data type nvarchar to datetime.
I have tried dssqlInsertEvent.InsertParameters.add("EventDate", convert.todatetime(txtEventDate.text)); wbut received another error.
Any assistance would be greatly appreciated.
View 4 Replies
View Related
Apr 9, 2015
Declare @specificDB nvarchar(max) = 'AdventureWorksDW2012'
,@tablename nvarchar(max) = 'DimAccount'
declare @localtab INT
SET @localtab = (SELECT Convert(INT,('select count(*) from ' + @specificDB+'.'+'INFORMATION_SCHEMA.Tables WHERE TABLE_TYPE = ''BASE TABLE'' AND Table_name = ' + @tablename)))
Print @localtab
Print @localtab
----
Msg 245, Level 16, State 1, Line 8
Conversion failed when converting the nvarchar value 'select count(*) from AdventureWorksDW2012.INFORMATION_SCHEMA.Tables WHERE TABLE_TYPE = 'BASE TABLE' AND Table_name = DimAccount' to data type int.
View 2 Replies
View Related