I've imported a CSV file into a table in SQL Server 2012. It's a large file, 140,000+ rows, so I couldn't covert it to Excel first to preserve the date format due to Excel's row limit. In the CSV file, there were 3 column with date data in "31-Aug-09" format, and the import automatically transformed these in "31AUG09" format (varchar(50)) in SQL Server. Now I need to convert these 3 columns from varchar to datetime so I could work with them in date format.
I need to take a temporary table that has various times stored in a text field (4:30 pm, 11:00 am, 5:30 pm, etc.), convert it to miltary time then cast it as an integer with an update statement kind of like:
Update myTable set MovieTime = REPLACE(CONVERT(CHAR(5),GETDATE(),108), ':', '')
how this can be done while my temp table is in session?
I hope to update a DateTime column value with a Time input parameter.  Poor attempt below but it looks like the @ApptTime param is coming in as 10:45:00.0000000 and I might have an existing @SendOnDate as: 2015-10-05 07:00:00.000...I hope to end up with 2015-10-05 10:45:00.000
ALTER PROCEDURE [dbo].[SendEditUPDATE] @QuePoolID int=null ,@ApptTime time(7) ,@SendOnDate datetime
Given a string it should convert it to a proper text.Example: if you passed a string 'Cat in the hat', I want 'Cat In TheHat'Curious about few things, Does sql have Instr OR Split(like VB)functionalityAnybody can help??
I have a column in a table that has a type TEXT,when I pull the length of a row it returns 88222 but when I select from that column it dows not show all the text in the result set.
I am trying to create custom reports with Access by linking to SQL tables in the SMS 2.0 software metering database. The only problem that I am having is trying to convert the internal SQL time/date nine digit format for when programs started or ended to a standard format. Is there a special function within either SQL or Access that will do this? Thanks.
I have a table that has a nvarchar field of (12) I need to convert this to a smalldatetimefield.
I get the following message
Error Source: Microsoft Data Transformation Services (DTS) Data Pump Error Description:Insert error, column 1 ('timeid', DBTYPE_DBTIMESTAMP), status 6: Data overflow. Error Help File:sqldts80.hlp Error Help Context ID:30702
Can someone please tell me how to convert this field without getting this message?????
how do you convert a numeric to time format if it shows hours but a decimal figure for Minutes. For example if I have hours in decimal format like this
In Reporting Services, I have a decimal time field (18,2) in my report which I wish to display as HH:MM. Similarly, I req a sum of total hours and minutes as a summary. Whats the expression for doing this. I've googled far and wide and cannot find a definitve solution.
I have a field that currently is displaying time in decimal form. I would like to convert it to time format. For example: when it displays 6.46 I would like it to be converted to 00:06:27. Can I do this within reporting services?
I am trying to convert the following working SQL Server query to query a DB2 database. I am getting the following error: An ON clause associated with a JOIN operator or in a MERGE statement is not valid. SQLSTATE=42972. Can anyone help me convert it? Thanks for your help!
I have a database table with 2 numeric fields. The values to be inserted into these fields come from text boxes in an ASP.NET page. So in the parameters to add into these fields I simply use 'textbox1.text' & textbox2.text'.
One of the fields accepts the data within the text box and adds it into the appropriate numeric data field in the table. However on the other text box I get an error message 'Error converting data type nvarchar to numeric.'
Does anyone know why this occurs just on the one entry and not the other?, and if anyone has any suggestions on how to get around this please let me know.
I am using DTS to import text to a table. This mostly works except for the 'DateTime' datatype where I always run into either 'Arithmetic overflow' or 'Unable to convert varchar to DateTime format.' I can convert same data without incident in Access.
I have a field that stores a date as text (121205). I need to convert this field to a date, but since it is text, I cannot figure out how to do it. Any ideas??? Thanks! :D
Hey,Another 'must be simple' question.. I'm wishing to convert a binaryfield into a textual representation of that binary data. i.e. come outwith what the query analyser would display, and not try to convert thebinary into ascii/whatever encoded text.Cheers for any clues,Chris
Hi,I have two tables. One of them has a text field, and the other has a numeric(integer) field that serves a similar purpose. I want to connect (UNIONactually) the two tables, and store the text from the first table in thesame field as the number from the other.For example:SELECT TextID AS IDFROM W1UNIONSELECT NumericID AS IDFROM W2The above query results in a type mismatch error due to trying to store anInt in a text field. I have tried the SQL CONVERT function, but the docsseem to indicate that it is just for Dates. In any case, it hasn't workedfor me.Any ideas?Thanks!
We did an in place convertion of our data base from MS SQL Server 6.5 to 7.0. Our application is much slower now on SQL 7.0. Any idea why? The following is a sample SQL statement that runs quickly on SQL 6.5 and takes a long time on SQL 7.0 I also attached the query plans from SQL 6.5 and 7.0.
SELECT Person_Name.PerNam_Person_Name_PK , Person_Name.PerNam_Row_Status , Person_Name.PerNam_Last_Name_Sndx , Person_Name.PerNam_Last_Name , Person_Name.PerNam_Name_Suffix , Person_Name.PerNam_First_Name , Person_Name.PerNam_Name_Prefix , Person_Name.PerNam_Middle_Name , Person_Name.PerNam_Event_Person_FK , Event.Evn_Event_Nbr , Event.Evn_Event_Type , Event_Person.EvnPer_Last_Name , Event_Person.EvnPer_First_Name , Event_Person.EvnPer_Middle_Name , Event_Person.EvnPer_Name_Prefix , Event_Person.EvnPer_Name_Suffix FROM Person_Name , Event , Event_Person WHERE (Person_Name.PerNam_Agency_ID = "CL") AND ( Person_Name.PerNam_Event_Person_FK = Event_Person.EvnPer_Event_Person_PK ) and ( Event_Person.EvnPer_Event_FK = Event.Evn_Event_PK ) and (Person_Name.PerNam_Person_Name_PK = 0 or ( Person_Name.PerNam_Event_Person_FK = 581541) ) and ( Person_Name.PerNam_Row_Status <> "D" )
Query plan in SQL 6.5
SQL Server Execution Times: cpu time = 0 ms. elapsed time = 31250 ms. STEP 1 The type of query is INSERT The update mode is direct Worktable created for REFORMATTING FROM TABLE Person_Name Nested iteration Index : PK_Person_Name FROM TABLE Person_Name Nested iteration Index : PerNam_Event_Person_FK FROM TABLE Person_Name Nested iteration Using Dynamic Index FROM TABLE Event_Person Nested iteration Index : PK_Event_Person TO TABLE Worktable 1 STEP 2 The type of query is SELECT FROM TABLE Worktable 1 Nested iteration Table Scan FROM TABLE Event Nested iteration Index : PK_Event SQL Server Parse and Compile Time: cpu time = 0 ms. Table: Person_Name scan count 2, logical reads: 6, physical reads: 5, read ahead reads: 0 Table: Event scan count 0, logical reads: 0, physical reads: 0, read ahead reads: 0 Table: Event_Person scan count 0, logical reads: 0, physical reads: 0, read ahead reads: 0 Table: Worktable scan count 0, logical reads: 0, physical reads: 0, read ahead reads: 0 Table: Worktable scan count 1, logical reads: 1, physical reads: 0, read ahead reads: 0
SQL Server Execution Times: cpu time = 0 ms. elapsed time = 62 ms.
converting date and/or time from character string.Got this error message: "Msg 241, Level 16, State 1, Line 7...Conversion failed when converting date and/or time from character string."
Here's my query: DECLARE @StartDate AS varchar(30) DECLARE @EndDate AS varchar(30) SET @StartDate = (CONVERT(varchar(20),'01-05-2014', 101)) SET @EndDate = (CONVERT(varchar(20),'31-05-2014', 101))
My organization have a web-based application and needs it to support multilingual so we will be adapting our app to use unicode. However, one of our problems is to convert existing data from text to ntext. I couldn't find anything that document this. What is the best way to do that? I would like to be able to migrate the data from an existing text column to another ntext column in the table.
If I can't do that, what are the options? If it's possible, I would like to be able to do this in sql script.
How to convert a SQL table into Text file? I have a table and I want to extract the values with the field names above to a text file. The query should also allow me to define the starting position of the fields in the text file.
New to the forums here. I'm not a beginner with SQL, but nor am I a SQL developer - network engineer who knows some scripting and the fundamentals of DB design/administration. There's the background.
I have a database of client information where a date is keyed in and stored as text. Because this is entered by end-users, the way it's entered varies - 1/1/2001, 01/01/2001, etc. Most use "1/1/2001" (note the date is not the same for each record)
I have 4,000 records to update and I need to try to convert the text string to the correct date - changing 1/1/2005 to the same date in proper date/time format. My database uses datetime as an integer calculating the number of days from 12/30/1800. Today's date would be 75508. Time is separated into different fields.
I can do the work to update the text to a single format to make the conversion easier, but I am having trouble locating the proper way to write a convert function to do this. I've searched online (which is how I came here) and have searched the forums without luck.
I have a table with over a million rows and one of the fields containsamounts of money in text format.What is the most efficient way of converting this field to a numberformat that I can sum on?Regards,Ciarán