Records Newer Than 90 Minutes (smalldatetime)
Jul 20, 2005Hi,
I have a table in SQLServer2000 where e.g. the actual time is insert for
every record (smalldatetime). But how do I select every records newer
than 90 minutes?
/Chris
Hi,
I have a table in SQLServer2000 where e.g. the actual time is insert for
every record (smalldatetime). But how do I select every records newer
than 90 minutes?
/Chris
Consider a table that holds Internet browsing history for users/machines,date/timed to the minute. The object is to tag all times that are separatedby previous and subsequent times by x number of minutes or less (it couldvary, and wouldn't necessarily be a convenient round number). This willenable reporting "active time" for users (a dubious inference, but hey).There are a lot of derivative ways of seeing this information that might begood to get to. What's the fist and last of these sets of times? Whatpercentage of a given period is spanned by active times, and not? What isthe average duration of such periods? What is the average interval betweenweb hits during such periods? During other times?Blah, blah. The basic problem is my principal problem. I don't have muchexperience with cursors, but from what I understand it would be very goodindeed to spare them, given the number of records I anticipate workingwith.I'd be glad of any pointers.--Scott
View 29 Replies View RelatedI have the following SQL select query:
Code:
SELECT
inbound_emails.inbound_email_id,
inbound_emails.campaign_id,
campaign_header.campaign_name,
customers.customer_name,
inbound_emails.date_received,
[Code] ....
Without any indexes (other than PK's) this query would take 1min 21 secs to return all 8500 records.
I wasn't satisfied with that so I added indexes to the tables.
Indexes are;
inbound_emails:
PK: inbound_email_id
1. campaign_id (non-unique, non-clustered)
2. email_from (non-unique, non-clustered)
3. email_to (non-unique, non-clustered)
campaign_header:
PK: campaign_id
1. campaign_name (unique, non-clustered)
customers:
PK: customer_id
1. customer_name (unique, non-clustered)
contracts:
PK: contract_id
1. contract_name (unique, non-clustered)
2. customer_id (non-unique, non-clustered)
Have I made a hash of the indexes? Or is the query statement badly written? What is a reasonable amount of time to expect to retrieve 8500 records?
I think email_from and email_to on inbound_emails is the main culprit, but I don't understand why?
I have the following generic table structure.
CREATE TABLE tableName (
...
, datetime_created datetime DEFAULT GetDate()
, created_by_user char(12)
)
I want to find out which records were created within a given period of time per user. For example I want to know if the user "georgev" (or any users) has created more than one record in this table within a 2 minute period.
Hopefully thsi will warm your brains this cold Monday morning :p
Any more information needed, let me know!
My table as data as follow,
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[table_Data]') AND type in (N'U'))
DROP TABLE [dbo].[table_Data]
GO
/****** Object: Table [dbo].[table_Data] Script Date: 04/21/2015 22:07:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[table_Data]') AND type in (N'U'))
[code].....
I need to parse some text files and load them to database - these files are mostly CSV files or fix width columns format and the column names (first line) may vary in text (e.g. different abbreviation), order and extra columns, etc.
Is it a good idea have this done using script task of SSIS? How it compare to Perl on performance? Or any other tools good for this?
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..... ?
One of my actual production environments is a Failover two-node cluster, SQL Server 2005 SP3 on Windows Server 2003 R2. Recently, the node 2 was failed, so I formatted a new machine to add the new node, but it failed with the following error: “Adding nodes to the Virtual Server definition using a newer version of Setup is not allowed.”I have searching across the web for a solution but I can’t find it.
The Summary file “Summary.txt” are:
Microsoft SQL Server 2005 9.00.1399.06
OS Version : Microsoft Windows Server 2003 family, Enterprise Edition Service Pack 2 (Build 3790)
Time
: Thu Jun 04 13:04:38 2015
[code]....
One point of my attention, it’s that the Product Version that appears on this summary file corresponding a 9.00.1399.06 that is to say, a RTM version, not SP3 (9.00.4035).Based on this, I went to the path where the files of installation are (ARPWrapper.exe), "C:Program FilesMicrosoft SQL Server90Setup Bootstrap"and I 've found that these files contain a different version of what I have currently installed. For example, in properties of ARPWrapper.exe the version of this is 2005.90.1399.0 The same goes for the rest of the files in that folder:
Microsoft.SqlServer.AnalysisServices.UpgradeAdvisor.dll
Microsoft.SqlServer.BestPracticesAnalyzer.UpgradeAdvisor.dll
Microsoft.SqlServer.DTS.UpgradeAdvisor.dll
setup.exe
Is it possible that the solution is to replace these files with the corresponding version, in this case the version 2005.90.4035.0(SP3) and continue with the installation?
In the For Loop, How to Iterate from Older flat files to Newer flat files based on File's Timestamp. If there are some older files in that folder, it should be processed first and then continue with the newer one.
Any Suggestions?
I am fairly new to VS 2005 and SQL Server CE. I have developed a Desktop Windows application using VB 2005 and the SQL Compact Edition Database. This application will sell to users via web download.
When they download a service patch, or updated version, I wish for them to retain the data in their present database. In other words, fill the new database with the old data. The new table structures will remain intact except for added columns at the end.
Question is how to save the old data and update the new database with it. Is there an easy way to do this, or do I need to write a module to save a database copy, and update the new database with content at install time?
Hello,
I have a package that has a data lfow task. this task imports data from a db2 database (using the IBM Ole DB provider fro db2) and adds it to sql server database table. This package was created on the server. then though version control (using TFS source control) I check out the package on my local machine. and when I open the package I get the foll 3 errors.
Error 1 Validation error. Import Account Num from BMGP_BDR: DTS.Pipeline: The component metadata for "component "DataReader Source" (1113)" could not be upgraded to the newer version of the component. The PerformUpgrade method failed.
Error 2 Error loading BMAG Download Xref Tables - bmag.dtsx: Microsoft.SqlServer.Dts.Pipeline.ComponentVersionMismatchException: The version of component "DataReader Source" (1113) is not compatible with this version of the DataFlow. [[The version or pipeline version or both for the specified component is higher than the current version. This package was probably created on a new version of DTS or the component than is installed on the current PC.]] at Microsoft.SqlServer.Dts.Pipeline.ManagedComponentHost.HostCheckAndPerformUpgrade(IDTSManagedComponentWrapper90 wrapper, Int32 lPipelineVersion)
Error 3 Error loading BMAG Download Xref Tables - bmag.dtsx: The component metadata for "component "DataReader Source" (1113)" could not be upgraded to the newer version of the component. The PerformUpgrade method failed.
Please advice.
Thank you.
Hi,
I have a package which reads an Access file from a folder. My connection manager to this file is .NET providers for OledbMicrosoft Jet 4.0 OLE DB Provider.
Package works from my computer. But when I execute it on the server as a SQL Agent job, I get
The component metadata for "component "DataReader Source" (1) could not be upgraded to the newer version of the component. The PerformUpgrade method failed.
I copied the mdb file to a folder on the server which my packages have no problem reading data from.
My packages run under the same domain account as defined in proxies.
Appreciate a help.
Gulden
writing the query for the following, I need to collapse the continuity. If the termdate for an ID is one day less than the effdate of the next id (for the same ID) i need to collapse the records. See below example .....how should i write the query which will give me the desired output. i.e., get min(effdate) and max(termdate) if termdate is one day less than the effdate of next record.
ID effdate termdate
556868 1999-01-01 1999-06-30
556868 1999-07-01 1999-10-31
556869 2002-10-01 2004-01-31
556872 1999-02-01 2000-08-31
556872 2000-11-01 2004-01-31
556872 2004-02-01 2004-02-29
output should be ......
ID effdate termdate
556868 1999-01-01 1999-10-31
556869 2002-10-01 2004-01-31
556872 1999-02-01 2000-08-31
556872 2000-11-01 2004-02-29
im getting this error while inserting into table (description of table given below)
mytable
mycode smallint identity,
mydataitem varchar(100),
mydatefrom smalldatetime,
mydateto smalldatetime,
myopcode smallint,
lastupdate smalldatetime
my sql statement was
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 ?
__________________
Cheers....
baburajv
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!
I need to convert a datetime field to smalldatetime.
This particular field we only care about the time portion (an example would be '1899-12-30 13:15:00.000')
For now I created another field say 'newTime' that is smalldatetime, in which I want to "update" to the smalldatetime version of the data. I know this will truncate the ms, but I don't care about that. Also the min date that can be used with smalldatetime is Jan 1 1900.
Not sure how to go about doing this.
Hi guys!
I need to convert datetime data type to smalldatetime on production
server with hundreds transactions per minute. In this case do I need to restrict users access to the table or put table in the single user mode?
Or it doesn't have any impact on productivity and I just can open Design table window in SQL Enterprise Manager and edit it?
Thank you in advance,
Igor
I am looking for just the date element of a datetime/smalldatetime col. For example the rows appear in typical datetime/smalldatetime format as:
1999-11-30 07:53:00
I need just "1999-11-30". So how do I strip off the time element? Datepart doesn't seem to be the route to take. I also need to use the date with Datediff so by stripping off the time element, I still need to keep the date element as a date datatype.
Thank you,
TW
In T-SQL, how can I create a smalldatetime containing the
first day of the month relative to a smalldatetime parameter.
Example:
CREATE PROCEDURE @x smalldatetime -- @x = '1999.3.15'
--
DECLARE @y smalldatetime
-- How do I set @y = '1999.3.1' ??
--
Thanks.
Tom
Hi, im have a problem with the Convert function in sql 7 enterprise
when i have the value '07-31-1967' format mm-dd-yyyy i recivied the error 296
The conversion of char data type to smalldatetime data type resulted in an out-of-range smalldatetime value
the sentence i use is
set @dfnacimien = (Convert(varchar(10),@dfnacimien,110))
Someone please help me!!!!
Hi,
My system has SQL Server 7.0. I am retrieving date from an asp page using ADODB, I get the date in 'mm/dd/yy' format when I use smalldatetime as my datatype. I am aware that smalldatetime datatype is supposed to retieve data in 'mm/dd/yyyy' format. Please let me know if you have any inputs on this.
Thanks,
Rashmi.
Rather than reinvent the wheel, can someone pass along a date/time function combination? I have a field of smallDateTime being used primarily for the time value - all rows have the same date. e.g., format is 10/22/2005 01:00:00 PM.
What's the easiest function combination to get all rows for day (then night) where day is defined as 6am-10pm (night is midnight-6am and 10pm-midnight). Thought I could use datepart and hh, but it doesn't give me 1 pm as the true miliary time of 13.
Many thanks.
Will someone please tell me how to pull the time out of a smalldatetime field.
The code i am trying to use is as follows:
Select datepart(hh:mm, TimeField1)
from table1;
This gives me an error. I have also tried datepart('hh:mm'... datepart("hh:mm"... and other variations but i cant get anything to work. Thanks in advance for any help!!
Hi,
I just want to get the value from a smalldatetime into time only in a SQL Statement
10/10/2005 10:00:00 AM --- > 10:00:00 AM
What would be the best approached?
Thanks,
Vince
Hello everyone. I am running into some small problems converting a smalldatetime field. I currently have 2005-10-17 00:00:00
in the field but what it to have forward slashes instead of th dash. I tried a few convert methods but not successful.
Does anyone have any ideas on how to make this work?
All help is appreciated.
SQL Server 2000
Used to know how to do this but am having no luck today. I have data coming in from a .txt file that gives me char strings for dates, e.g. 02242003 for Feb. 2, 2003.
Need to whomp this into small datetime with the whole convert/cast thing but I guess I've previously only gone the other way--smalldatetime to char.
Thanks!!!
Hi im having trouble with SQL datatypes. i am trying to insert into a cell a date, month and day are retrieved from a drop down box whereas the year is retrieved from a textbox.
Also SQL datatypes only allow either 'datetime' and 'smalldatetime'. I am using SmallDateTime (i dont understand why sql doesn't have just a 'date' type)
Either way when i use the below code it inserts the month and day but when it comes to the year, it will always insert either 2001 or 2002 even if thats not what i put in the text box.
'VARIABLES
Dim month As String = DropDownList1.SelectedIndex + 1
Dim day As String = DropDownList2.SelectedItem.Text.ToString()
Dim year As String = dobTextBox.Text.ToString()
'PARAMETER
cmd.Parameters.Add("@dob", SqlDbType.SmallDateTime).Value = month + "/" + day + "/" + year
Anyone understand why it is doing this?
If you think you know it all?! You know nothing!
What would the proper way to write the following query be? Thanks in advance.
Select * from mydb where smalldatetimefield > today's date.
Hello all and thank you for your time.I have a datagrid where I want to view dates (smalldatetime) and beable to sort on the field. However, I do not want to have the timepart show. If I use the convert function(convert(char,ProjDate,101) asProjDate) the field is then a char and does not sort correctly.Any solutions?Thanks again,Sunshine
View 3 Replies View RelatedI have a table that contains transactional data. Such as site view bywhom, when, which template, etc, etc...Everytime when I pulled the report, hh:mm:ss never matters. Onlybreakdown by dates, not time.Having read some chapters of Ralph Kimball's book, I am inspired tobuild "date" table with integer as primary key.Here's what I have for schema of transactional table.- viewed_customer_id int (4bytes)- template_id uniqidentifier (16 bytes)- viewed_on datetime (8 bytes)And here's the version I am thinking of building- viewed_customer_id int (4bytes)- template_id uniqidentifier (16 bytes)- viewed_date_key int (4 bytes)- seconds int (4 bytes)* I put seconds just in case I need to retrieve hour based or minutebased report.Here's my question. I've also noticed that smalldatetime is also 4bytesof memory but it consists of 2 sets of 2 bytes.When I index, would there be significant performance difference betweenindexing 4 byte of column and indexing 2bytes x 2 of column?
View 7 Replies View RelatedSorry to clutter the board with something so simple... but 'm very, very new at this.
What is the result of adding '1' to a smalldatetime type value?
for example, if a smalldatetime value @timebiscuit had the value 8/31/2007 4:00:00 PM, then what would
@timebiscuit + 1
return? What would I add to @timebiscuit to get 9/1/2007 4:00:00 PM? Thanks.
-steve
Hi,
Ive Got a field like 2008-02-14 00:00:000
and another field like 18:30:00 (NVARCHAR(8))
I want to merge this 2 fields in a single field (SMALLDATETIME) to get the following output 2008-02-14 18:30:00
Any clue about the best way to obtain this output ?
Thanks in advance.
I am trying to insert data into a table that has two smalldatetime columns
I am using the following code
INSERT INTO dbo.Orders
SELECT TAX_ID, Customer_ID, InvoiceNumber, DeliveryCharge, TimeSlot_ID, convert(CHAR(8), DateStamp, 112), convert(CHAR(8), DeliveryDate, 112) , Order_ID
FROM dbo.Pending_Orders
I have tried a few different things but I keep getting the error
Arithmetic overflow error converting expression to data type smalldatetime.
Or must use Convert
when I try CAST AS smalldatetime
Also, Can some please tell me where I can get information about the mask number i.e. 112
Thanks