Hi,
when I convert a field into smalldatetime from nvarchar(50) in Sql Server 2000, i got a default value (1900-01-01 00:00:00) for that field.Actually value of that field to be changed as different values).I want to be convert bulk of records.please help me.
I am using Visual Studio 2005 and SQL Express 2005. The database was converted from MS Access 2003 to SQL Express by using the upsize wizard.
I would like to store the current date & time in a column in a table. This column is a smalldatetime column called 'lastlogin'.
The code I'm using is:
Dim sqlcommand As New SqlCommand _
("UPDATE tableXYZ SET Loggedin = 'True', LastLogin = GetDate() WHERE employeeID = '" & intEmployeeID.ToString & "'", conn)
Try
conn.Open()
sqlcommand.ExecuteNonQuery()
conn.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
This code works fine on my local machine and local SQL server. However at the client side this code results in the error as mentioned in the subject of this thread. I first used 'datetime.now' instead of 'getdate()', but that caused the same error. Then I changed the code to 'getdate()', but the error still remains.
The server at the client is running Windows Server 2000 UK . My local machiine is running WIndows XP Dutch.
Maybe the conversion from Dutch to UK has something to do with it. But this should be solved by using the 'Getdate()' function..... ?
Hi All, I am trying to convert date from a character string field 12 to another database which has smalldatetime. Is there a way to do this. Any help would be greatly appriciated.
Hi, I'm making a webapplication in C# with MSSQL as database. I've created a form to do an advanced search on books. The user can type in name, author, .... and he can also mark 2 dates from to Calendar objects (I made sure date one can not be bigger than date 2). I'm using smalldatetime as DBtype. The 2 selected values are DateTime in asp. The results are shown in a gridview. Since I added the feature I keep getting the same error and I can't find where it is. Here's some code: 1 public List GetBooks2(string invB,string titelB, string auteursB, string taalB, string uitgeverijB, string jaarB, string keywordsB, string categorieB, string standplaatsB, string ISBN,DateTime datum1, DateTime datum2, string sortExpression) 2 { //this is my method for the advanced search 3 using (SqlConnection oConn = new SqlConnection(_connectionString)) 4 { 5 string strSql = "select * FROM Boek where 1 = 1"; 6 if (!String.IsNullOrEmpty(invB)) strSql += " and (inventaris_nr like @invB)"; 7 if (!String.IsNullOrEmpty(titelB)) strSql += " and (titel like @titelB)"; 8 if (!String.IsNullOrEmpty(auteursB)) strSql += " and (auteurs like @auteursB)"; 9 if (!String.IsNullOrEmpty(uitgeverijB)) strSql += " and (uitgeverij like @uitgeverijB)"; 10 if (!String.IsNullOrEmpty(ISBN)) strSql += " and (ISBN10 like @ISBN or ISBN13 like @ISBN)"; 11 if (!String.IsNullOrEmpty(standplaatsB)) strSql += " and (standplaats like @standplaatsB)"; 12 if (!String.IsNullOrEmpty(jaarB)) strSql += " and (jaartal like @jaarB)"; 13 if (!String.IsNullOrEmpty(keywordsB)) strSql += " and (keywords like @keywordsB)"; 14 if (!String.IsNullOrEmpty(taalB)) 15 if (taalB == "Andere") 16 strSql += " and (taal NOT IN ('nederlands', 'frans', 'engels', 'spaans', 'italiaans', 'duits'))"; 17 if (taalB == "--Geen voorkeur--") 18 strSql += ""; 19 else 20 strSql += " and (taal like @taalB)"; 21 22 if (!String.IsNullOrEmpty(categorieB)) 23 if (categorieB == "--Selecteer een categorie--") 24 strSql += ""; 25 else 26 strSql += " and (categorie like @categorieB)"; 27 28 if (datum1 == null) 29 strSql += ""; 30 else 31 if (datum2 != null) 32 { 33 34 strSql+=" and datumB between @datum1 and @datum2"; 35 } 36 else strSql+=""; 37 if (!String.IsNullOrEmpty(sortBLOCKED EXPRESSION 38 strSql += " order by " + sortExpression; 39 else 40 strSql += " order by id"; 41 42 SqlCommand oCmd = new SqlCommand(strSql, oConn); 43 oCmd.Parameters.Add(new SqlParameter("@invB", "%" + invB + "%")); 44 oCmd.Parameters.Add(new SqlParameter("@titelB", "%" + titelB + "%")); 45 oCmd.Parameters.Add(new SqlParameter("@auteursB", "%" + auteursB + "%")); 46 oCmd.Parameters.Add(new SqlParameter("@taalB", "%" + taalB + "%")); 47 oCmd.Parameters.Add(new SqlParameter("@uitgeverijB", "%" + uitgeverijB + "%")); 48 oCmd.Parameters.Add(new SqlParameter("@jaarB", "%" + jaarB + "%")); 49 oCmd.Parameters.Add(new SqlParameter("@keywordsB", "%" + keywordsB + "%")); 50 oCmd.Parameters.Add(new SqlParameter("@categorieB", categorieB )); 51 oCmd.Parameters.Add(new SqlParameter("@standplaatsB", "%" + standplaatsB + "%")); 52 oCmd.Parameters.Add(new SqlParameter("@ISBN", "%" + ISBN + "%")); 53 oCmd.Parameters.Add(new SqlParameter("@datum1", "%" + datum1 + "%")); 54 oCmd.Parameters.Add(new SqlParameter("@datum2", "%" + datum2 + "%")); 55 56 57 oConn.Open(); 58 SqlDataReader oReader = oCmd.ExecuteReader(); 59 List boeken = GetBoekCollectionFromReader(oReader); 60 oReader.Close(); 61 return boeken; 62 } 63 }
I think that that method is correct, not sure though... The code for GetBoekCollectionFromReader(oReader) is this=1 protected List GetBoekCollectionFromReader(IDataReader oReader) 2 { 3 List boeken= new List(); 4 while (oReader.Read()) //THIS IS WHERE THE ERROR APPEARS 5 { 6 boeken.Add(GetBoekFromReader(oReader)); 7 8 } 9 return boeken; 10 }
That's the method where the error appears... Where should I place a breakpoint to get the exact location? To make sure all methods in this code are explained, here's the code for GetBoekFromReader(oReader))= 1 protected Boek GetBoekFromReader(IDataRecord oReader) 2 { 3 Boek boek = new Boek(); 4 boek.idB= (int)oReader["id"];//id auto generated dus verplicht 5 if(oReader["inventaris_nr"] != DBNull.Value) 6 boek.Inventaris_nrB = (string)oReader["inventaris_nr"]; 7 if (oReader["auteurs"] != DBNull.Value) 8 boek.AuteursB = (string)oReader["auteurs"]; 9 boek.TitelB = (string)oReader["titel"];//titel verplicht 10 if (oReader["taal"] != DBNull.Value) 11 boek.TaalB = (string)oReader["taal"]; 12 if (oReader["uitgeverij"] != DBNull.Value) 13 boek.UitgeverijB = (string)oReader["uitgeverij"]; 14 if (oReader["aantal_p"] != DBNull.Value) 15 boek.Aantal_pB = (string)oReader["aantal_p"]; 16 if (oReader["jaartal"] != DBNull.Value) 17 boek.JaartalB = (int)oReader["jaartal"]; 18 if (oReader["keywords"] != DBNull.Value) 19 boek.KeywordsB = (string)oReader["keywords"]; 20 if (oReader["categorie"] != DBNull.Value) 21 boek.CategorieB = (string)oReader["categorie"]; 22 if (oReader["standplaats"] != DBNull.Value) 23 boek.StandplaatsB = (string)oReader["standplaats"]; 24 if (oReader["ISBN13"] != DBNull.Value) 25 boek.ISBN13 = (string)oReader["ISBN13"]; 26 if (oReader["ISBN10"] != DBNull.Value) 27 boek.ISBN10 = (string)oReader["ISBN10"]; 28 if (oReader["URL"] != DBNull.Value) 29 boek.UrlB = (string)oReader["URL"]; 30 if (oReader["username"] != DBNull.Value) 31 boek.UsernameB = (string)oReader["username"]; 32 if (oReader["passwoord"] != DBNull.Value) 33 boek.PasswoordB = (string)oReader["passwoord"]; 34 if (oReader["datumB"] != DBNull.Value) 35 boek.DatumBoek = (DateTime)oReader["datumB"]; 36 if (oReader["status"] != DBNull.Value) 37 boek.StatusB = (string)oReader["status"]; 38 39 40 return boek; 41 }
Conversion failed when converting datetime from character string. That's the error I get by the way. It also appears when I do a search and I don't use the date function... for example when I only fill in the title textbox and I don't select any dates from the calendars... Sorry for the long post, but I think it's the only way to get a clear view on it...
I am newbie in asp and sql, and I am using VS & SQL expresswhen I try to submit I get following error"Conversion failed when converting character string to smalldatetime data type"Following is my insert statement<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:oncallConnectionString %>"SelectCommand="SELECT data.* FROM data" InsertCommand="INSERT INTO data(Apps, Location, Impact, System, Date, Start_Time, End_Time, Duration, Problem, Cause, Solution, Case, Comments) VALUES ('@DropDownList1','@DropDownList2','@DropDownList3','@TextBox6','@DropDownCalendar1','@DropDownCalendar2','@DropDownCalendar3','@TextBox1','@TextBox2','@TextBox3','@TextBox4','@TextBox5','@TextBox7')"></asp:SqlDataSource>These are @DropDownCalendar1','@DropDownCalendar2','@DropDownCalendar3' defined as datetime in database.I would appriciate if somebody could help.
Hello, I have problem with this code.(This program presents - there is GridView tied to a SQL database that will sort the data selected by a dropdownList at time categories. There are 2 time categories in DropDownList - this day, this week. Problem: when I choose one categorie in dropDownlist for examle this week and submit data on the server I got this error. Conversion failed when converting character string to smalldatetime data type. Here is code: <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server">
I am running the following query: select distinct hqvend, hqvprd,fprod,idesc,ilead,sum(cast(fqty as int) )as fqty, (cast(hqvend as varchar(5))+'/'+ltrim(rtrim(fprod))+'/'+cast(ilead as varchar(3))) as Keydata,'L1/'+rtrim(fprod) as LocPartno from tblkfpl01 inner join hqtl01 on (fprod=hqprod) inner join iiml01 on (hqvend=ivend and hqprod=iprod) where cast(cast(hqeff as varchar(8)) as smalldatetime) <= (Select CONVERT(varchar(8), getdate(), 1)) and cast(HQDIS as varchar(8)) >= (Select CONVERT(varchar(8), getdate(), 1)) and hqvend like '134%' group by hqvend,fprod,hqvprd,idesc,ilead order by hqvend,fprod The bold sections are giving me the error message. The query works as written above, butis only evaluating on one date, contained in hqeff. However, when I try to modify the second date, HQDIS, by casting it the same way as the one before it: select distinct hqvend, hqvprd,fprod,idesc,ilead,sum(cast(fqty as int) )as fqty, (cast(hqvend as varchar(5))+'/'+ltrim(rtrim(fprod))+'/'+cast(ilead as varchar(3))) as Keydata,'L1/'+rtrim(fprod) as LocPartno from tblkfpl01 inner join hqtl01 on (fprod=hqprod) inner join iiml01 on (hqvend=ivend and hqprod=iprod) where cast(cast(hqeff as varchar(8)) as smalldatetime) <= (Select CONVERT(varchar(8), getdate(), 1)) and cast(cast(HQDIS as varchar(8)) as smalldatetime) >= (Select CONVERT(varchar(8), getdate(), 1)) and hqvend like '134%' group by hqvend,fprod,hqvprd,idesc,ilead order by hqvend,fprod I get the error message. I need to select based on both dates (hqeff AND HQDIS), but cannot seem to be able to it.... Both fields are of type Dedimal, with a length of 8, and dates stored in them look like: 20071003 (YYYYMMDD). Any suggestions?
I have SQL Server 2005 database table with the following data definition as follows:
ID int LST_TIME varchar(5) LST_DATE varchar(21) LST_WEEK int SUBJECT varchar(100)
Date format (Month,day YEAR) eg.- October, 21 2007 Time format, 00 - 23 hours, HH:MM eg. - 18:58
, and a VB code as below:
Dim Command As New SqlClient.SqlCommand("SELECT * FROM dbo.LISTS WHERE (LST_WK = DATEPART(wk, GETDATE())) AND (CONVERT(datetime, LST_DATE) = CONVERT(datetime, CONVERT(varchar, GETDATE(), 110))) AND(CONVERT(smalldatetime, LST_TIME) = CONVERT(smalldatetime, CONVERT(varchar(5), GETDATE(), 108)))", conn)
Dim dataReader As SqlClient.SqlDataReader = Command.ExecuteReader(CommandBehavior.CloseConnection) While dataReader.Read()
Dim NewAlert As New Alert(dataReader("SUBJECT").ToString(), DateTime.Parse(dataReader("LST_DATE").ToString(), DateTime.Parse(dataReader("LST_TIME").ToString())))
: : : I am encountering error: System.Data.SqlClient.SqlException: Conversion failed when converting character string to smalldatetime data type, which points to the codes in bold. Just wondering anyone out there has got a solution to my problem. Thank you.
Recently i traspased a database from sql server 2000 in spanish to sql server 2005 in english. I change the language of the user sa to spanish and the database is in spanish. . The problem is our dateformat is dmy, i try to force with set dateformat dmy, but always i execute a stored procedure that have a date as input it fail. The error is:
Msg 295, Level 16, State 3, Procedure pa_CalendarioGestion, Line 40 Conversion failed when converting character string to smalldatetime data type.
The code of stored procedure in this line is:
set @diaActual = dateadd("d", @i, @fechaInicio)
This stored procedure in sql server 2000 in spanish not have any problems. For this reason i think the problem is in the configuration.
The transaction_date is datetime and date1 is nvarchar. When I run the script: Insert into payment(transaction_date) Select convert (datetime, date1) from dep01
I get the following message:
Server: Msg 8115, Level 16, State 2, Line 1 Arithmetic overflow error converting expression to data type datetime. The statement has been terminated.
Can someone please explain to me how the datapages in Microsoft SQL Server 2000 works. The pages are supposed to be 8K, that is 8192 bytes of which only 8060 are accessible for data storage (due to overhead). Now, I currently have a table containing 8 fields. Two of these fields are varchar and should be converted to nvarchar. One of the varchar fields is limited to 255 characters and the other to 4000 characters. When I convert the 255 characters field to nvarchar it works just fine, but when I want to convert the 4000 characters field I get an error from MS SQL saying that it gets to big. Is the error only for the 4000 characters field (which growths to 8000 bytes when using nvarchar instead of varchar) or must the whole table fit into one datapage? Could a blob maybe solve my problem, or will I face new problems when storing unicode characters in a blob?
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?
Hi Group,I am new with SQL Server..I am working with SQL Server 2000.I am storing the date in a nvarchar column of atable.... Now I want toshow the data of Weekends..Everything is OK...But the problem isarising with Conversion of nvarchar to date...to identify theweekends...Like..Here DATEVALUE is a nvarchar column...But getting theerror..Value of DATEVALUE like dd-mm-yyyy...04-08-2004-----------------------------------------------------------Server: Msg 8115, Level 16, State 2, Line 1Arithmetic overflow error converting expression to data type datetime.---------------------------------------------------------------------------Actual Query-------------------------------Select DATEVALUE,<Other Column Names> from Result whereDatepart(dw,convert(Datetime,DATEVALUE))<>1 andDatepart(dw,convert(Datetime,DATEVALUE))<>7-----------------------------------------------------------Thanks in advance..RegardsArijit Chatterjee
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.
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],
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.
I am facing a problem while using SQL Server with VB application.Implicit conversion from datatype text to nvarchar is not allowed.Use the convert function to run this query.When i see the trace file, i see one stored procedure called but nolines of code get executed, and immediately after that the ROLLBACKTRANSACTION occurs and the applications fails.But to my surprise i am able to do the same thing on a differentmachine using the same application and the same database on the sameserver with the same user id.Can anyone explain the reason of occurance of this problem.I require this very urgently, so i will be oblized if anyone can comeup with a quick response.Kind Regards,Amit Kumar
I am using Sql server 2005, Asp.net 2.0. In my application i have to store a mobile number in database, and in table it is declared as nvarchar(50) (datatype). In stored procedure as it is nvarchar(50). In my code , stored procedure is called in a function. In that while executing project error is coming as (cmd.ExecuteNonQuery) Conversion failed when converting the nvarchar value xxxxxxxxx to data type int. Kindly give your suggestions to solve this problem.
HiAm Using ASP.NET With SQL SERVER 2005 Backend AGENT CODE 3008000003
NAME agent code dropdownlist values like 1005000006,2009000002,3008000003select dropdownlist value it display corresponding values related to that codewhen i select first 2 values its run properly,But when i select 3008000003 i will get following error messagein SQL SERVER 2005 Agent Code Date Type is "bigint"" The conversion of the nvarchar value '3008000003' overflowed an int column. Maximum integer value exceeded. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: The conversion of the nvarchar value '3008000003' overflowed an int column. Maximum integer value exceeded.Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: Please Help me to solve this issueThanks With RegardsS.Senthil Nathan
I can't seem to fix the following error in my stored procedure.
Error Message: Conversion failed when converting the nvarchar value '1007-001' to data type int.
The line of code in my stored procedure that seems to be the problem is the following:
CASE WHEN [Order Details].[Job No] IS NULL THEN [Orders].[Order No] ELSE [Order Details].[Job No] END
Order No has a data type of INT and Job No has a data type NVARCHAR(8). In the above case statement i'm not trying to convert anything but just display a column depending on the out come of the case statement. If anyone knows how to get around this error you help would be very welcome.
I want to get Email address from sql database. But whenever I executed stored procedure I get an error message "Conversion failed when converting the nvarchar value 'xxxxxx@xxxxxx' to data type int" If I want some numeric ID it is worked.
I also change my SP like this but results same.
ALTER procedure [dbo].[findConsultantMail]
(
@PerID nvarchar(18),
@perMail nvarchar(100) OUTPUT
)
as
SELECT @perMail=PerMail FROM Personel
WHERE (PerID =cast(@PerID as numeric(18,0)))
return cast(@perMail as nvarchar(100))
How can I get a string value form stored procedure.
HI, I am running the below method which returns this error: The parameterized query '(@contactdate nvarchar(4000),@dnbnumber nvarchar(4000),@prospect' expects the parameter '@futureopportunity', which was not supplied" Please help.Private Shared Sub InsertData(ByVal sourceTable As System.Data.DataTable, ByVal destConnection As SqlConnection) ' old method: Lots of INSERT statements Dim rowscopied As Integer = 0 ' first, create the insert command that we will call over and over: destConnection.Open()Using ins As New SqlCommand("INSERT INTO [tblAppointmentDisposition] ([contactdate], [dnbnumber], [prospectname], [businessofficer], [phonemeeting], [followupcalldate2], [phonemeetingappt], [followupcalldate3], [appointmentdate], [appointmentlocation], [appointmentkept], [applicationgenerated], [applicationgenerated2], [applicationgenerated3], [comments], [newaccount], [futureopportunity]) VALUES (@contactdate, @dnbnumber, @prospectname, @businessofficer, @phonemeeting, @followupcalldate2, @phonemeetingappt, @followupcalldate3, @appointmentdate, @appointmentlocation, @appointmentkept, @applicationgenerated, @applicationgenerated2, @applicationgenerated3, @comments, @newaccount, @futureopportunity)", destConnection) ins.CommandType = CommandType.Textins.Parameters.Add("@contactdate", SqlDbType.NVarChar) ins.Parameters.Add("@dnbnumber", SqlDbType.NVarChar)ins.Parameters.Add("@prospectname", SqlDbType.Text) ins.Parameters.Add("@businessofficer", SqlDbType.NChar)ins.Parameters.Add("@phonemeeting", SqlDbType.NVarChar) ins.Parameters.Add("@followupcalldate2", SqlDbType.NVarChar)ins.Parameters.Add("@phonemeetingappt", SqlDbType.NVarChar) ins.Parameters.Add("@followupcalldate3", SqlDbType.NVarChar)ins.Parameters.Add("@appointmentdate", SqlDbType.NVarChar) ins.Parameters.Add("@appointmentlocation", SqlDbType.NVarChar)ins.Parameters.Add("@appointmentkept", SqlDbType.NVarChar) ins.Parameters.Add("@applicationgenerated", SqlDbType.NVarChar)ins.Parameters.Add("@applicationgenerated2", SqlDbType.NVarChar) ins.Parameters.Add("@applicationgenerated3", SqlDbType.NVarChar)ins.Parameters.Add("@comments", SqlDbType.Text) ins.Parameters.Add("@newaccount", SqlDbType.NVarChar)ins.Parameters.Add("@futureopportunity", SqlDbType.NVarChar) ' and now, do the work: For Each r As DataRow In sourceTable.RowsFor i As Integer = 0 To 15 ins.Parameters(i).Value = r(i) Next ins.ExecuteNonQuery() 'If System.Threading.Interlocked.Increment(rowscopied) Mod 10000 = 0 Then 'Console.WriteLine("-- copied {0} rows.", rowscopied) 'End If Next End Using destConnection.Close() End Sub
INSERT INTO mytable (mydataitem,mydatefrom,mydateto,myopcode,lastupdat e) VALUES ('SAMPLEDATA','01/01/2003','18/05/2003',1,'05/Mar/2004')
THE ERROR RETURNED IN MY CLIENT APP IS [Microsoft][ODBC SQL Server Driver][SQL Server]The conversion of char data type to smalldatetime data type resulted in an out-of-range smalldatetime value.
AND THAT IN QA IS
Server: Msg 296, Level 16, State 3, Line 1 The conversion of char data type to smalldatetime data type resulted in an out-of-range smalldatetime value. The statement has been terminated.
can ne 1 point out the mistake in my sql statement ?
I have an Execute SQL Task that pulls the max date from a sql table.
SELECT max(date_Idx) FROM dbo.FactDailyInventorySnapshot
This field is defined as a smalldatetime. I want to store this max date in a variable in SSIS called LastDate.
Then in a data flow, in an OLE DB Source, I want to use it as a parm in a sql command to compare to a smalldatetime field.
My question is, what type of variable do I declare it in in SSIS, and what is the correct parameter mapping inside of my sql query? I thought I had exhausted all combinations of variable types and parameter types. I have even tried casting it as different data types when I do the exec sql task of getting the max date. Any help would be appreciated. Thanks!