A Simple Update Query Using A Date - Conversion From Msaccess

Mar 21, 2005

I'm converting an ASP system from using msaccess to SQL Server as the db engine, and I'm stumped on the following query





update


timecard


set


TcdDate = #3/18/05#








TcdDate is defined as a date/time type





It will not run with the date bracketed by # signs, and when I take them out, 1/1/1900 is stored in the dbs. Is there a different symbol to bracket the date with or should I be using a function to convert the date?

View 4 Replies


ADVERTISEMENT

Conversion MSAccess -&&> SSCe

Dec 6, 2006

We have plan to migrate our database from Access to SqlCe.

Here our situation:

We will never use a Pocket PC applications, only Windows desktop application.
We want to migrate the .mdb file to a .sdf file (I've seen the ADS application, but since we don't use mobile devices, it's no use)
The .sdf will be use on local client machine only.
Here's my problems:

I've use a conversion to migrate from access (http://www.primeworks-mobile.com/Downloads/DPW.html) and seem to work fine.
I updated the source code to use the SqlServerCe dll instead of OleDB.
Some of my queries work fine, but others just won't work in VS2005 using C#.

To check if the query is really wrong, I take exactly the same query and put it Query Builder from the Server Explorer in VS2005.
And the query just work fines!!! It's bring back all the records asked for, and I've got an error for the same query from my source code.

I'm using a datatable, here's the code used for filling the DataTable. I've got an error on the line adapter.FillSchema()






string connectionString = @"Data Source=" + fic_parent.CheminFichierComplet;
using (SqlCeConnection connection = new SqlCeConnection(connectionString))
{
SqlCeDataAdapter adapter = new SqlCeDataAdapter();

connection.Open();

SqlCeCommand command = new SqlCeCommand(requete, connection);

command.CommandType = CommandType.TableDirect;
adapter.SelectCommand = command;

tableResultats = new DataTable();
adapter.FillSchema(tableResultats, SchemaType.Source);
adapter.Fill(tableResultats);

// Close connection
connection.Close();
}



Error is:

Message="The specified table does not exist. [ (...) ]"
Source="SQL Server 2005 Everywhere Edition ADO.NET Data Provider"
HResult=-2147217865
NativeError=0

Here my questions:

Is it possible to have an application that will convert my Access databases to an SSCe .sdf file ?
Why I can query in Server Explorer and can't in my source code using the same sql statement ?

At which level my code isn't good, because I just replace all OleDB* --> SqlCe* in my code.
I hope that I explain clearly my problem, do not hesitate to ask me questions about this problem.

View 8 Replies View Related

Conversion Error From DBTYPE_DBTIMESTAMP To Datetime On Linked Server To MSAccess DB

May 18, 2008



Hi
I have a linked server to MSAccess DB and, when I try to select record from a table that have a column
with a bad date formatted (with year less than 1753) I receive the message:
.... conversion error from DBTYPE_DBTIMESTAMP to datetime....

My scope is set to NULL this bad values from Sql Server ...
I first try with something like

UPDATE LNK_SVR...TABLE SET FLD=NULL WHERE ISDATE(FLD)=0

But I receive the same error... perheaps the provider generate the error before an Sql Server evaluation ...

So I think to a passthrought query:


exec sp_serveroption @server='LNK_SVR',@optname='rpc out',@optvalue='true'


exec LNK_SVR...sp_executesql 'update table set FLD=NULL WHERE YEAR(FLD)<1753'

But I receive the folowing message ....


Messaggio 7213, livello 16, stato 1, riga 1

Il provider non è riuscito a passare parametri di stored procedure remota al server remoto 'LNK_SVR. Verificare che il numero, l'ordine e il valore dei parametri passati siano corretti.

Any suggestion is appreciate.
Thanks in advance

Matteo





Mds

View 10 Replies View Related

Help With A Simple Update Query..

Feb 5, 2007

hi, i've just started using sql server 2005 and visual studio, i have made 3 stored procedures, an update, insert and delete. The update one doesn't work but the others do so i'm on the right track with them..

is there anything obvious i am missing in the following update stored procedure? All of the datatypes and names line up with the datatypes/sizes/names in the table..


Code:

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
-- =============================================
-- Author:<Author,,Name>
-- Create date: <Create Date,,>
-- Description:<Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[spUpdateAddresses]
-- Add the parameters for the stored procedure here
(@addressID int, @fname varchar(50), @lname varchar(50), @address01 varchar(50), @address02 varchar(50), @suburb varchar(50), @state varchar(50), @postcode char(10), @comments varchar(1250), @phone char(10), @fax char(10), @mobile char(10))

AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
Update addresses
set @fname=fname, @lname=lname, @address01=address01, @address02=address02, @suburb=suburb, @state=state, @postcode=postcode, @comments=comments, @phone=phone, @fax=fax, @mobile=mobile
where (@addressID = addresses.addressID)

END

View 2 Replies View Related

Simple Update Query Help

Feb 27, 2007

Hi, wondered if anyone here can help out with an SQL query thats been driving me mad. Currently I do this programmatically in a C# program with a hard coded mapping class but want to put the new codes into a table and run an update query instead.

2 tables like this;

Table: CarModels
SORT
GROUP_CODE
MODEL_NAME
PK: SORT

Table: NewGroupCodes
OLD_CODE
NEW_CODE
PK: OLD_CODE, NEW_CODE

Basically I want to update all GROUP_CODE entries in the CarModels table with the NEW_CODE values from NewGroupCodes where there is a match between CarModels.GROUP_CODE and NewGroupCodes.OLD_CODE.

thanks in advance,
afro

View 7 Replies View Related

Simple SQL Question Regarding Update Query

Oct 5, 2006

Can we add if statements in Update query?

I have to do following task in one stored proc:
I am passing 2 param to the stored proc @spkid, @Repspk

Update myTable
set spk1=@Repspk
where spk1=@spkid

Update myTable
set spk2=@Repspk
where spk2=@spkid

Update myTable
set spk3=@Repspk
where spk3=@spkid


Instead of writing 3 update statements what is the other option that will make the query run faster? Thanks alot for transfering knowledge...

View 1 Replies View Related

Simple Update Query Problem....

Nov 20, 2006

Hi,

I have a table called "Cust_Vehicle_Specialisation" consisting columns named "Vehicle_Specialisation_Id", "Motortrade_Id" and Effectdate(datetime).

My data in the table consists like this..

Vehicle_Specialisation_Id Motortrade_Id Effectdate

A94ACDEE 007094C1 2006-05-16 13:01:00.000
2EC8B2BF 007094C1 2006-06-05 12:19:00.000
A1C617D2 007094C1 2006-06-12 17:37:00.000
458C5F70 007094C1 2006-07-25 09:44:00.000
139954DE 007094C1 2006-08-01 12:05:00.000
1F3D7BDB E1A50F16 2006-05-22 12:00:00.000
F85EA44A E1A50F16 2006-07-14 15:05:00.000
489700E8 E1A50F16 2006-08-21 12:59:00.000


I want to update the Vehicle_Specialisation_Id records for the same Motortrade_Id and the minimum effectdate record. In other words i want my outout like this..

Vehicle_Specialisation_Id Motortrade_Id Effectdate

A94ACDEE 007094C1 2006-05-16 13:01:00.000
A94ACDEE 007094C1 2006-06-05 12:19:00.000
A94ACDEE 007094C1 2006-06-12 17:37:00.000
A94ACDEE 007094C1 2006-07-25 09:44:00.000
A94ACDEE 007094C1 2006-08-01 12:05:00.000
1F3D7BDB E1A50F16 2006-05-22 12:00:00.000
1F3D7BDB E1A50F16 2006-07-14 15:05:00.000
1F3D7BDB E1A50F16 2006-08-21 12:59:00.000

I have wriiten a SP to do this one but it is a bit slow and i have quarter million records in my table. So i want a simple and single update query to do this one.

Cheers

Praveen

View 3 Replies View Related

DeadLock On Simple Update Query.

Jan 2, 2008



I am tring to execute the simple update query in query analyiser but after some seconds process got block by the same process(DEADLOCK).

query:

update tablename
set col1 = 0

Other info may help you:
Database had 3 different primary data files. In these files, first two files restricted file growth option is selected and there size is full. Only third file has space and option to grow.
Table containts total 50 columns and 15 milion rows.

Please help me to solve this ASAP.
Thanks in advance.

View 12 Replies View Related

Simple Date Range Query

Apr 30, 2007

Hello

I was wondering if someone could tell me the syntax for a simple date range query. Basically:



select * from TABLE where start date= and end date =



Thanks

View 3 Replies View Related

Simple Todays Date Query Question

Jan 19, 2007

Hi, I have just started using SQL server 2005 reporting. But I am stuck on my select part of the report. I want to bring back all results from a table for todays date (whatever that would be). I have tried:

Where ColumnA = Today()

and a few other Today variations.

Can anybody please help?

Also is there a good site / tutorial which helps with SQL syntax, statements, etc.

Thanks

Dan

View 4 Replies View Related

Question MSDE: Query Analyzer Vs MSAccess ADP

Oct 3, 2005

Hi all!

I have one UDF which take 5 params. When I run this UDF from Query Analyzer (select * from dbo.UDFname (param1, ..., param5)), it take 5 seconds, but when I run from ADP project (doble click), it take > 200 seconds. In both situations I obtain the same result (of course). I look at the connexion, seems ok (File -> Connexion; in .adp).

Can anybody tell me why are this differences? And how to surpass this ? I want to use the access .adp to make one front to run a MSDE db.

Thank's in advance :)

koci.

View 2 Replies View Related

Question MSDE: Query Analyzer Vs MSAccess ADP

Sep 30, 2005

Hi all!

I have one UDF which take 5 params. When I run this UDF from Query Analyzer, it take 5 seconds, but when I run from ADP project (doble click), it take > 200 seconds. I look at the connexion, but I don't see nothing to change (File -> Connexion; in .adp).

Can anybody tell me why?

Thank's in advance :)

koci.

View 1 Replies View Related

Help Wanted Msaccess PIVOT-query --&> MS-SQL View/sp

Jan 18, 2006

Can someone help me parsing this ms-access PIVOT sql-statement to ams-sql-server sql-statement?Many thanks in advanceTRANSFORM Count(KlantenStops.id) AS AantalVanidSELECT KlantenStops.Uitvoerder, KlantenStops.KlantFROM KlantenStopsGROUP BY KlantenStops.Uitvoerder, KlantenStops.KlantPIVOT DatePart("m",leverdatum,1,0) In("1","2","3","4","5","6","7","8","9","10","11","12");

View 3 Replies View Related

Select And Update Query For Date

Nov 20, 2007

Hi Friends,
I need a select query to identify how many records violate the basic dateformat, later on i update the junkdata with null.
Initially I have a database, in which one field(for Date) is given as Varchar, now as we know varchar accepts all types of data, when migrating the same data to another server, i am using Date as datatype for the new field and want to remove all other format's of data (Junk data) entered to that field and want to ratain only the general format i.e, MM/DD/YYYY or MM/DD/YYYY, this query should also support MM<=12, DD<=31
Regards,
Prasad K

View 2 Replies View Related

Msaccess To Mssql Server Query Parser/convertor

Jul 23, 2005

Hi all,is there any tool which is capable to convert query initially written formsaccess database to query for mssql server.I have tons of queries which contains iif, trim and similar functions whichshould be converted to case, ltrim(rtrim(, etc. etc.Does anyone know for tool which could do that automatically?Thanks in advance,Anabella

View 1 Replies View Related

Date Function - Conversion Failed When Converting Date And / Or Time From Character String

Mar 18, 2014

I have the following

Column Name : [Converted Date]
Data Type : varchar(50)

When I try and do month around the [Converted Date] I get the following error message

“Msg 241, Level 16, State 1, Line 2
Conversion failed when converting date and/or time from character string.”

My Query is

SELECT
month([Created Date])
FROM [FDMS_PartnerReporting].[Staging].[Salesforce_MarketingReporting]

View 7 Replies View Related

Transact SQL :: Due Date - Conversion Failed When Converting Date And / Or Time From Character String

Nov 16, 2015

SELECT * ,[Due]
  FROM [Events]
 Where Due >= getdate() +90

This returns the error: Conversion failed when converting date and/or time from character string

Why would this be? How to cast or convert this so that it will work? 

View 24 Replies View Related

Flat File Text Date Conversion To SQL Server Date Comments And Suggestions

Mar 12, 2008

Hi,
Basically the above is a very common requirement, please comment on my solution which I've arrived at by searching through the web; -

In summary I have used 3 SSIS components these are "Flat File Source", "Derived Column" and "SQL Server Destination".

1) File Connections Manager Editor
1.1) Within File Connections Manager Editor; -
Name the data type e.g. "INTERCHANGE_NET_APP_DATE_SRC"
and assign a type to the data type e.g. string[DT_STR]

1.2) Click on the Preview button to ensure the expected text is assigned to the expected data type.


2) Derived Column Transformation Editor
2.1) Assign Derived Column Name, e.g.
INTERCHANGE_NET_APP_DATE

2.2) Select <add as new column> within Derived Column.

2.3) Enter the conversion Expression, e.g. ; -
2.3.1)
(SUBSTRING(INTERCHANGE_NET_APP_DATE_SRC,8,2) + "/" + SUBSTRING(INTERCHANGE_NET_APP_DATE_SRC,5,2) + "/" + SUBSTRING(INTERCHANGE_NET_APP_DATE_SRC,1,4))

2.3.2)
Since the above conversion is such a common task I suggest that Service Pack 3 of SQL Server 2005 delivers the following functionality; -

STRINGTODATE ('YYYYMMDD',INTERCHANGE_NET_APP_DATE_SRC)

2.4) Select "database timestamp [DT_DBTIMESTAMP] " as Data Type.

2.5) Within the Mappings tab of the SQL Destination Editor have; -
Input Column as INTERCHANGE_NET_APP_DATE and
Destination Column as INTERCHANGE_NET_APP_DATE.

Please comment on the above, I will then pass on my suggestion to Microsoft.

Thanks in advance,

Kieran.

View 1 Replies View Related

Conversion Of Oracle Date Time To Sql Server Date Time In SSIS

Jun 30, 2007

This is driving me nuts..



I'm trying to extract some data from a table in oracle. The oracle table stores date and time seperately in 2 different columns. I need to merge these two columns and import to sql server database.



I'm struggling with this for a quite a while and I'm not able to get it working.



I tried the oracle query something like this,

SELECT
(TO_CHAR(ASOFDATE,'YYYYMMDD')||' '||TO_CHAR(ASOFTIME,'HH24:MM : SS')||':000') AS ASOFDATE

FROM TBLA

this gives me an output of 20070511 23:06:30:000



the space in MM : SS is intentional here, since without that space it appread as smiley



I'm trying to map this to datetime field in sql server 2005. It keeps failing with this error

The value could not be converted because of a potential loss of data



I'm struck with error for hours now. Any pointers would be helpful.



Thanks

View 3 Replies View Related

Date Conversion

Aug 6, 2005

i do have date problem in sql server, i m using DD/MM/YYYY date format, & passing it to insert & update stat...& compairing it with data in table, which is not working properly, how to convert dd/mm/yyyy to mm/dd/yyyy or yyyy-mm-dd
hoping for solution soon, thanx
murli ......

View 7 Replies View Related

Date Conversion

Sep 21, 2005

I'm searching on a smalldatetime field in SQL Server so a typical value would be 09/21/2005 11:30:00 AM.  I have a search form which offers the user a textbox to search by date and unless they enter the exact date and time, no matching records are found.  Of course I want I all records for a given day to be returned.  This is how I'm doing it now. Thanks.
Dim dteDate_Requested As String = txtDate_Requested.Text
If dteDate_Requested <> "" Then   strSqlText += " Date_Requested='" & dteDate_Requested & "'"End If

View 5 Replies View Related

Conversion To Date

Feb 17, 2006

HI everyne,
I have a varchar field in one table, which contains data in the form '010706' and I want to convert this to date datatype to 01/07/2006 (Jan 07, 2006). When I just import the data to the other table it gets converted to 7/6/2001, how can I convert it right? Please help.

View 2 Replies View Related

Date Conversion

Mar 19, 2001

Hello All,

I need help in converting a date. What i'm looking for is date in format of mm/yyyy.

Thanks in advance.

View 1 Replies View Related

Date Conversion

Nov 27, 2001

I need to import a text file into a table by using DTS.

How to convert a text date to smalldate type ?

Thanks.

View 1 Replies View Related

Date Conversion

Aug 11, 2003

Hi all

I wonder whether any of you can help me with a bit of code that you may have already had to execute??

I have a SQL database logging activities and a load of information in a mdb file that needs to be imported.

Unfortunately the data in the SQL database is in the format yyyy-mm-dd and the data in the mdb file is in dd/mmmm/yyyy.

When i run a DTS to import the data the new rows are imported as they were YYYY-dd-mm.:mad:

example:
data logging as
2003-08-10
2003-08-11

imported data from last week arrives as
2003-01-08
2003-02-08
2003-03-08
etc

how can i manipulate the data in SQL to reverse the day and month numbers for Aug 1st to Aug 8th??

I have tried changing the mdb data format but that doesnt make a difference. I dont understand DTS enough to know whether it is possible there :confused: and my SQL skills dont rise to the challenge - yet!! :o

TIA

View 2 Replies View Related

Date Conversion

Oct 29, 2003

I have a datetime field in a table and I have to insert this datatime data into antoher table. In my insert statement I convert the datetime field into varchar and then insert it into the second table.

The date field in the original table is : 2/2002/13 3:58:12 PM
but in the destination table i get: 2/2002/13 3:58:00 PM

I lose the seconds in the conversion, i think

Whats the best way to preserve to the datetime field during transfer?

thanks

View 3 Replies View Related

Date Conversion Help

Mar 6, 2002

I have one column that is a datetime, and another that is an INT which represents seconds. i cannot figure out how to subtract the seconds from the datetime column. sorry, i'm still kind of new to this TSQL. I get this error:Server: Msg 8115, Level 16, State 2, Line 1
Arithmetic overflow error converting expression to data type datetime.

when i try to do this
select dateColumn - IntColumn from Table

so i think there must be a way to make sql know that IntColumn is actually seconds. thanks

View 2 Replies View Related

Date Conversion ?

Jan 19, 2004

Is use this stored procedure.
This is the error mesage: "Syntax error converting datetime from character string"

Please help me !

Alter Procedure "Selectie_Date_Tabel" (@datainceput datetime, @datasfirsit datetime,@Grupa AS nvarchar(20))

As

set nocount on

DECLARE @NEWLINE AS char(1)

SET @NEWLINE = CHAR(10)

DECLARE @keyssql AS varchar(1000)


SET @keyssql = 'SELECT * FROM View2'
+ @NEWLINE + 'WHERE [Cod grupa] = ' + CHAR(39) + @Grupa + CHAR(39)
+ @NEWLINE + 'AND ([Day] BETWEEN ' + CONVERT(DATETIME, @datainceput , 120) + ' AND ' + CONVERT(DATETIME, @datasfirsit , 120) +')'

EXEC (@keyssql)

View 12 Replies View Related

Date Conversion Help

Jan 28, 2004

Hi,

I have my dates in DB2 source in two formats -

Format 1 - char(5) - Example - 10305. 1 indicates century,03 indicates year and 05 indicates month. The day is not stored. So this is 2003,May 1

Format 2 - char(7) - Example - 1030525. 1 indicates century,03 indicates year, 05 indicates month,25 indicates day. 2003,May 25

I want to convert the above two formats to SQL Server smalldatetime and I only need the DATEPART. The date needs to be in the format mm/dd/yyyy. The default day would be 01 when the day is not specified.

If the format is 00305 then the 0 indicated 19th century. So this is 1903, May 1.

Any help is appreciated.


Thanks,

Vivek

View 7 Replies View Related

Date Conversion

Apr 25, 2008

Hi am trying to convert my date from the date times stap to
this format 250408

I've tried this : select convert(varchar,getdate(),112)
but the result am getting is '20080425'

View 3 Replies View Related

Sql Date Conversion

Jun 15, 2006

priya writes "select convert(smalldatetime,'09/06/2006') is working

select convert(smalldatetime,'13/06/2006') it shows an error
The conversion of char data type to smalldatetime data type resulted in an out-of-range smalldatetime value.

why it shows an error"

View 1 Replies View Related

Date Conversion

Feb 6, 2008

I have a SQL database where the dates appear in the format "733433".
If you convert in the "Select" statement, it's fine. You can use the day, month, year concatenated in an excel expression, converts fine. As an expression in reporting services, I receive an error. An help is appreciated.

View 1 Replies View Related

Date Conversion

Apr 4, 2006

I need help with date conversion from character data. In SQL 2000 we used a Date Time Conversion task

I do not see how to do this in SQL 2005 SSIS. I tried a data conversion task to a database timestamp and this is what I got:

[Data Conversion [383]] Error: Data conversion failed while converting column "date_time_stamp" (47) to column "Copy of date_time_stamp" (396). The conversion returned status value 2 and status text "The value could not be converted because of a potential loss of data.".

Here is a sample of the input data I'm trying to convert.

input data example - 2006-03-07-14.42.34

Any ideas? .

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved