Dates Prior To 1753-01-01
Jul 23, 2005
Hello,
I have an Access DB with a column [date] holding dates from present day back
to around year 1702, and I am trying to run DTS Import with this MDB, which
fails due to a conversion error.
MSDN says the datetime data type only allows 1753-01-01 to 1900-01-01, thus
I am under the impression having the [date] field as varchar is the only way
to store the dates.
My questions are:
a) Can dates prior to 1753-01-01 be stored in a date column?
b) If dates are in a column of type varchar (or similar) is it possible to
sort them chronologically with T-SQL ?
c) 1753-01-01 seems particularly arbitrary, any reason for this?
Many thanks for any help, it's driving me mad!
John
View 6 Replies
ADVERTISEMENT
Jan 13, 2000
I've set up a SQL7 database with MSAccess97 as a front end. I'm trying to enter a person with a birthdate prior to 1900, get an ODBC call error, "Datetime field overflow". How to enter dates prior to year 1900?
Thanks.
View 1 Replies
View Related
Aug 19, 2007
i am write an archive program, there are some date before 1/1/1753, but there are a constraint of system.data. How can i fix this. Could i change the minimum data to 1/1/1200.
SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
View 2 Replies
View Related
Apr 19, 2002
According to books online, a datetime data type is:
Date and time data from January 1, 1753 through December 31, 9999, to an accuracy of one three-hundredth of a second.
So how do I have a date before 1753??!? possible?!?
TIA,
-Henry
View 2 Replies
View Related
Feb 21, 2007
I cannot for the life of me figure out why im still getting this
error. I have tried everything i can think of from using dbnull.value
to setDOBnull() to datetime.minvalue. Can anyone help me? Here's the code on my BLL:
Public Function AddEmployee(ByVal SSN As String, ByVal FirstName As
String, ByVal LastName As String, ByVal PreferredName As String, ByVal
MaidenName As String, ByVal MaritalStatus As Nullable(Of Char), ByVal
DOB As Nullable(Of Date), ByVal Gender As Nullable(Of Char), ByVal
Ethnicity As String, ByVal StartDate As Nullable(Of Date), ByVal
TerminationDate As Nullable(Of Date)) As Boolean ' Create a new employeeRow instance Dim employees As New HRMS.EmployeesDataTable() Dim employee As HRMS.EmployeesRow = employees.NewEmployeesRow() Dim sqldatenull As SqlDateTime sqldatenull = SqlDateTime.MinValue.Value employee.SSN = SSN employee.FirstName = FirstName employee.LastName = LastName If PreferredName Is Nothing Then employee.SetPreferredNameNull() Else employee.PreferredName = PreferredName If MaidenName Is Nothing Then employee.SetMaidenNameNull() Else employee.MaidenName = MaidenName If Not MaritalStatus.HasValue Then employee.SetMaritalStatusNull() Else employee.MaritalStatus = MaritalStatus.Value If Not DOB.HasValue Then employee.SetDOBNull() Else employee.DOB = DOB.Value If Not Gender.HasValue Then employee.SetGenderNull() Else employee.Gender = Gender.Value If Ethnicity Is Nothing Then employee.SetEthnicityNull() Else employee.Ethnicity = Ethnicity
If StartDate = DateTime.MinValue Then employee.StartDate =
SqlDateTime.MinValue.Value Else employee.StartDate = StartDate.Value 'If StartDate = DateTime.MinValue Then employee.SetDOBNull() Else employee.StartDate = StartDate.Value 'If Not StartDate.HasValue Then employee.StartDate = sqldatenull Else employee.StartDate = StartDate.Value
If TerminationDate = DateTime.MinValue Then employee.TerminationDate =
SqlDateTime.MinValue.Value Else employee.TerminationDate =
TerminationDate.Value P
View 8 Replies
View Related
Jul 16, 2007
Hi there...
i have a search page with consitst of DatePicker and DataView
this is how i'm binding my dataview
<asp:ObjectDataSource runat="server" EnableCaching="false" ID="ods" TypeName="daab.Employee" SelectMethod="GetEmployee"> <SelectParameters> <asp:ControlParameter ControlID="DatePicker1" ConvertEmptyStringToNull="true" PropertyName="SelectedDate" Name="SearchDate" Direction="Input" Type="DateTime" /> </SelectParameters> </asp:ObjectDataSource>
..........................................................................................
the searchDate is optional user may select date from datepicker or leave it blank if (!string.IsNullOrEmpty(DatePicker1.SelectedDate))
{ //
}
else
{
this.ods.SelectParameters["SearchDate"].DefaultValue = DBNull.Value.ToString();
}
when i execute the above code i get this error:, what i'm missing?
error Message = "SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM."
View 10 Replies
View Related
Apr 10, 2008
hey,
i will make calender(by use Asp.net 2003 - C# - framework 2.0 ) that stored and retreive data from Database(SQL Server 2000), that success , but if add this function (Calendar1_DayRender)
Server Error in '/bwarq' Application.
SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM. 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.SqlTypes.SqlTypeException: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.Source Error:
Line 1999:DA.SelectCommand.Parameters.Add("@eventdate",eventdate);
Line 2000:DataTable DT=new DataTable();
Line 2001:DA.Fill(DT);
Line 2002:DA.SelectCommand.Connection.Close();return DT;
Line 2003:}
Source File: c:inetpubwwwroot4paldataaccess.cs Line: 2001
and i want to see my files here:
1- DataAccess(put here Stored proceure)public static DataTable GetCalendar(DateTime eventdate)
{SqlDataAdapter DA=new SqlDataAdapter("GetCalendar",createConn());
DA.SelectCommand.CommandType=CommandType.StoredProcedure;
DA.SelectCommand.Parameters.Add("@eventdate",eventdate);DataTable DT=new DataTable();
DA.Fill(DT);DA.SelectCommand.Connection.Close();return DT;
}
2- User Control Page
private void Calendar1_SelectionChanged(object sender, System.EventArgs e)
{
DataTable DT=DataAccess.GetCalendar(Calendar1.SelectedDate);if(DT.Rows.Count == 0)
{DGEvent.Visible = false;
}
else
{DGEvent.Visible = true;
DGEvent.DataSource=DT;
DGEvent.DataBind ();
}
}private void Calendar1_DayRender(object sender, System.Web.UI.WebControls.DayRenderEventArgs e)
{
DataTable DT2=DataAccess.GetCalendar(Calendar1.SelectedDate);
// If the month is CurrentMonthif (! e.Day.IsOtherMonth )
{for(int i=0 ; i< DT2.Rows.Count;i++)
{if ((DT2.Rows[i]["eventdate"].ToString() != DBNull.Value.ToString()))
{
DateTime dtEvent= (DateTime)DT2.Rows[i]["eventdate"];if (dtEvent.Equals(e.Day.Date))
{
e.Cell.BackColor = Color.PaleVioletRed;
}
}
}
}
//If the month is not CurrentMonth then hide the Dates
else
{
e.Cell.Text = "";
}
}
so, i want the exaclty solution for this problem,plz
View 1 Replies
View Related
Apr 17, 2008
Yes, I've parsed many a topic on many a site regarding this issue.sigh.I am using a calendar control within a TemplateField on a DetailsView.I know that my SQL DB will accept NULL for my DATETIME field, because if I don't bind the control to the insert, the insert succeedes, yeilding a null for DATETIME in the new record.My problem is that I want the user to be able to choose to not select a date. I find that I have to bind selected value to the insert parameter, so that if they do select a date, it get inserted.( duhh!! ) When I do though, and the user does not select a date, I get the above error.My best guess? it is sending a datetime value of 00:00:0000 00:00:00 (or something like that anyhow)?So... does anyone have any ideeas on a simple way to evaluate the value when the form is submitted? and how to set it to NULL if it is, for example "in the past" or "00:00:0000....." ?
,Gary"We truly fail, only when we quit."
View 11 Replies
View Related
Dec 1, 2005
Hi. I am getting the error described in the title - SqlDateTime overflow. I have read what is available online but am still not able to get rid of it. Help much appreciated... thanks.
The Full Error Is:
Code:
System.Data.SqlTypes.SqlTypeException: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM. at System.Data.SqlTypes.SqlDateTime.FromTimeSpan(TimeSpan value) at System.Data.SqlTypes.SqlDateTime.FromDateTime(DateTime value) at System.Data.SqlTypes.SqlDateTime..ctor(DateTime value) at System.Data.SqlClient.MetaType.FromDateTime(DateTime dateTime, Byte cb) at System.Data.SqlClient.TdsParser.WriteValue(Object value, MetaType type, Int32 actualLength, Int32 encodingByteSize, Int32 offset, TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.TdsExecuteRPC(_SqlRPC[] rpcArray, Int32 timeout, Boolean inSchema, SqlNotificationRequest notificationRequest, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at ASP.audiobook_viewdetails_aspx.DetailsView1_ItemInserting(Object Src, DetailsViewInsertEventArgs Args) in C:InetpubwwwrootdushkinmediasupportwebPresentationTieraudiobook_servicesaudiobook_viewdetails .aspx:line 151
And, below is the method that is raising the errors. The
culprit is "created_date" as "DateTime".
Code:
Sub DetailsView1_ItemInserting(ByVal Src As Object, ByVal Args As DetailsViewInsertEventArgs)
'validate the controls
If Args.Values("ISBN") = "" Then
Args.Cancel = True
MSG.Text = "-- Missing ISBN number"
End If
If Args.Values("author_first") = "" Then
Args.Cancel = True
MSG.Text = "-- Missing first name"
End If
If Args.Values("author_last") = "" Then
Args.Cancel = True
MSG.Text = "-- Missing last name"
End If
If Args.Values("publisher") = "" Then
Args.Cancel = True
MSG.Text = "-- Missing Publisher"
End If
If Args.Values("text_description") = "" Then
Args.Cancel = True
MSG.Text = "-- Missing item description"
End If
If Not IsNumeric(Args.Values("regular_price")) Then
Args.Cancel = True
MSG.Text = "-- regular price is not numeric"
Else
If Args.Values("regular_price") < 0 Then
Args.Cancel = True
MSG.Text = "-- regular price is out of range"
End If
End If
If Not IsNumeric(Args.Values("discount_price")) Then
Args.Cancel = True
MSG.Text = "-- Discount price is not numeric"
Else
If Args.Values("discount_price") < 0 Then
Args.Cancel = True
MSG.Text = "-- Discount price is out of range"
End If
End If
'if all the controls are valid, decalre the types
Dim audiobookID As Integer
Dim title As String
Dim author_first As String
Dim author_last As String
Dim publisher As String
Dim ISBN As String
Dim regular_price As String
Dim discount_price As String
Dim text_description As String
Dim created_date As DateTime
' ||||| Set up a Connection Object to the SQL DB
Dim MyConn As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection("server=ARIA;database=dushkinmedia;Integrated Security=SSPI")
' ||||| Pass in the StoreProcedure or Command String, as well as the Connection object
Dim MyCmd As New System.Data.SqlClient.SqlCommand("sp_RegisterNewAudioBook", MyConn)
' ||||| Set the Command Type (Stored Procedure, Text, etc)
MyCmd.CommandType = System.Data.CommandType.StoredProcedure
' ||||| Create Parameter Objects for values passed in
Dim objParam1, objParam2, objParam3, objParam4, objParam5, objParam6, _
objParam7, objParam8, objParam9, objParam10, objParam11, objParam12, _
objParam13, objParam14, objParam15 As System.Data.SqlClient.SqlParameter
' ||||| Add your parameters to the parameters Collection
objParam1 = MyCmd.Parameters.Add("@audiobookID", Data.SqlDbType.Int)
objParam2 = MyCmd.Parameters.Add("@title", Data.SqlDbType.VarChar)
objParam3 = MyCmd.Parameters.Add("@author_first", Data.SqlDbType.VarChar)
objParam4 = MyCmd.Parameters.Add("@author_last", Data.SqlDbType.VarChar)
objParam5 = MyCmd.Parameters.Add("@publisher", Data.SqlDbType.VarChar)
objParam6 = MyCmd.Parameters.Add("@ISBN", Data.SqlDbType.VarChar)
objParam7 = MyCmd.Parameters.Add("@regular_price", Data.SqlDbType.VarChar)
objParam8 = MyCmd.Parameters.Add("@discount_price", Data.SqlDbType.VarChar)
objParam9 = MyCmd.Parameters.Add("@text_description", Data.SqlDbType.Text)
objParam10 = MyCmd.Parameters.Add("@created_date", Data.SqlDbType.DateTime)
'objParam10 = MyCmd.Parameters.AddWithValue("@img_name", imgName)
objParam11 = MyCmd.Parameters.AddWithValue("@img_data", System.Data.SqlDbType.Image)
'objParam12 = MyCmd.Parameters.AddWithValue("@img_contenttype", imgcontenttype)
'objParam13 = MyCmd.Parameters.AddWithValue("@aud_name", audName)
objParam14 = MyCmd.Parameters.AddWithValue("@aud_data", System.Data.SqlDbType.VarBinary)
'objParam15 = MyCmd.Parameters.AddWithValue("@aud_contenttype", audcontenttype)
' ||||| Set the Parameter values to the passed in values
objParam1.Value = audiobookID
objParam2.Value = title
objParam3.Value = author_first
objParam4.Value = author_last
objParam5.Value = publisher
objParam6.Value = ISBN
objParam7.Value = regular_price
objParam8.Value = discount_price
objParam9.Value = text_description
objParam10.Value = created_date
'objParam11.Value = imgBinaryData
'objParam14.Value = audBinaryData
Try
' ||||| Check if Connection to DB is already open, if not, then open a connection
' ||||| DB not already Open...so open it
MyConn.Open()
MyCmd.ExecuteNonQuery()
' ||||| Close the Connection Closes with it
MyConn.Close()
Catch e As Exception
Beep()
MSG.Text = e.ToString
End Try
'Response.Redirect("~/audiobook_services/audiobook_view.aspx")
End Sub
Any help at all would be MUCH appreciated... Thanks in advance.
View 2 Replies
View Related
Jun 27, 2006
Hi,
Is there a way to catch the exeption (SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM) with in SQL Server, so it does not need to be caught in the code calling the procedure. E.g. I do not want to send null to the stored procedure.
e.g. The stored procedure should be able to catch dates that are outside the range 1/1/1975 and 12/31/9999 and change them to the limits.
E.g.
IF @StartDate < CONVERT(DateTime, '01/01/1753 12:00:00')
BEGIN
SET @StartDate = CONVERT(DateTime, '01/01/1753 12:00:00')
END
IF @EndDate > CONVERT(DateTime, '01/01/1753 11:59:59')
BEGIN
SET @EndDate = CONVERT(DateTime, '12/31/9999 11:59:59')
END
This still throws an exception because the StartDate or EndDate when tested fail the condition.
View 7 Replies
View Related
Mar 26, 2007
Hi,
I have a flat file that is read in by SSIS and then populates our db.
In this flat file there are blank spaces that represent null entries, which are date time values that we need to remain null but instead shows up in the table as the lowest date time value (1753)
Does SSIS automatically convert this since this is not done in our code?
Regards
Mike
View 13 Replies
View Related
Jul 8, 2015
I have connected to SQL SERVICES ANALYSIS SERVICE database through excel and when I observed that value of the date attribute is displayed as ######## in the excel for 1/1/1753.
I am able to see the value 1/1/1753 in the Cube browser but not able to see the vale in the excel.
how to replace this value with blank in the excel.
View 3 Replies
View Related
Mar 2, 2006
SQL 2005 Dev
How can I do this with Parameters? I can get a single parameter to filter for a single date (or even a combo list of the dates in DB). But I want my parameters to interact so that they specify a range. Is this possible?
View 3 Replies
View Related
Jul 18, 2014
Today I have got one scenario to calculate the (sum of days difference minus(-) the dates if the same date is appearing both in assgn_dtm and complet_dtm)/* Here goes the table schema and sample data */
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[temp_tbl]') AND type in (N'U'))
DROP TABLE [dbo].[temp_tbl]
GO
CREATE TABLE [dbo].[temp_tbl](
[tbl_id] [bigint] NULL,
[cs_id] [int] NOT NULL,
[USERID] [int] NOT NULL,
[code]....
View 9 Replies
View Related
Feb 28, 2015
I have a table that has hotel guests and their start stay date and end stay date, i would like to insert into a new table the original information + add all days in between.
CREATE TABLE hotel_guests
(
[guest_name] [varchar](25) NULL,
[start_date] [date] NULL,
[end_date] [date] NULL,
[comment] [varchar](255) NULL
[code]...
View 7 Replies
View Related
Aug 4, 2004
Hello,
I have to migrate an application from oracle to sqlserver but i habe query with
connect by prior
What is the equivalent in sqlserver 2000.
Please help me.
View 2 Replies
View Related
Mar 1, 2006
Is there any way to check 1-2 days prior sql queries executed..??
However, i am going for auditing now.
Thanks,
Pavan
View 1 Replies
View Related
Apr 13, 2006
Hello, Is there a way to do a prior omit in a SELECT?
I currently have multiple selections separated by a GO, but I need to prior Omit the rows I selected prior
so I have
select * from mytabe where
Address <> ' ' and
Zip4 <> ' ' and
zip in ('12345')
Go
select * from mytabe where
Address <> ' ' and
Zip4 <> ' ' and
Purchcode in ('A','C')
Go
This continues for another 10 selections I need to constantly omit the selections made above.
Is there a way to do this in SQL?
Thanks!
View 2 Replies
View Related
Jun 21, 2005
I want to know if there is a way to compare dates in the sql statement with dates that I input into a database and todays date. the datatype that I'm using is smalldatetime.The statement I used is:Select Date from Table where Date > 'Today.now'I get an errorCould this be done or is there another approach?
View 1 Replies
View Related
Dec 29, 2003
I'm trying to find out if a certain row exists in my table, if it does exist then I do nothing if it doesn't exist I will insert a value. Only problem is i'm quite new and not sure how to get the values from the insert to correctly check if they already exist. Heres my attempt using query analyser
DECLARE @FK_UserID int, @NoteID int, @BeenRead NVARCHAR(10), @TMPuserID INT, @TMPnoteID INT
SET @FK_UserID = 1
SET @NoteID = 254
SET @BeenRead = 'MyTestHere'
SELECT DISTINCT Backup_UserNotes.BackUp_UserID, Backup_UserNotes.BackUp_NoteID
FROM User_Notes INNER JOIN
Note ON User_Notes.FK_UN_NoteID = Note.NoteID INNER JOIN
Backup_UserNotes ON Note.NoteID = Backup_UserNotes.BackUp_NoteID
WHERE BackUp_UserID = @FK_UserID AND BackUp_NoteID = @NoteID
SELECT @NoteID = @@IDENTITY
SELECT @FK_UserID = @@IDENTITY
IF @FK_UserID = NULL AND @NoteID = NULL
BEGIN
INSERT BackUp_UserNotes (
BackUp_NoteID,
BackUp_UserID,
BackUp_Read)
SELECT @NoteID, @FK_UserID, @BeenRead
END
-- RETURN 0
------------------------------------------------
GO
Anybody know the best solution? Thanks
View 1 Replies
View Related
Apr 7, 2006
I can't figure this out for the life of me. Wanted to know if it's possible to select certain date conditions in a query, then later reference those conditions and to only select the max of them.
I need to do this dynamically as I do not know what the max value is. I've provided an example below:
Select var1
From table1
where
(
(Date1 = '11/30/2005')
OR
(Date1 = '12/31/2005')
)
and Date1 = (Max of previously selected values e.g. '12/31/2005')
What I can't figure out is how to dynamically retrieve the max of 11/31/2005 and 12/31/2005. Any ideas are greatly appreciated.
View 1 Replies
View Related
Apr 8, 2004
Hello gurus, I have a table of data containing stop and start times of equipment, such as this:
StartTime....................EndTime
12/01/01 15:44...........12/01/01 18:44
12/02/01 3:44............12/02/01 14:44
12/02/01 15:22...........12/02/01 15:33
etc.
With this, I can build a query that subtracts the start and end dates to give me the total differences between each record... But, how do I write a query that can count the elapsed time between the current record's "start time" and the prior record's "end time" to give me the elapsed time between each record?
View 14 Replies
View Related
Feb 29, 2008
One more question.
I need to use select using some type of a prior omit.
for example, I have 2 selects:
select * from table abc where zip in ('07661') and name like 'A%'
go
select * from table abc where zip in ('07661') and company like 'ABC&'
there could be common records in both select statements, but I want to exclude the same records from the first select when I run my second one.
I could say
select * from table abc where zip in ('07661') and company like 'ABC&' and name not like 'A%'
in my second select, but I rather not do that, since my queries has many select criterias and its not just 2 selects.
So is there another option? a subsitution for "go"?
thanks
View 3 Replies
View Related
May 13, 2002
I have a scheduled job that will do a database restore at given time every day. Sometimes I run into a situation where some people leave themselves logged on to the database, which prevents the job from running.
Is there a way that I can set up my job to include killing any open processes against the database that I'm restoring prior to the restore being done?
View 3 Replies
View Related
Aug 11, 2003
This is quite a tricky one for me to figure out.
I have a datetime field in a databse for when a tender closes. More often then not its 4pm - for what its worth. And I want to send an email informing the manager 6hrs, 30mins prior and when the tender closes. So I need to somehow check that field either once a day and store those times somewhere or quite regularly ... like every hour.
I would be interested to hear how people would approach such a concept. I havn't got a great deal of experience in triggers or SQL mail.
It is in an asp file that I am doing it.
Any ideas would be hugely appreciated.
Cheers
tom
View 1 Replies
View Related
Nov 13, 2003
I am trying to make a connection to sql server using sspi (windows authentication), however, I do not wish to use the built in tokenauthentication system. Administrators are worried about somebody using an unattended logged on computer to gain access to the database. So I am left with using sql server authentication (which I am not fond of doing, more password administration) or what I would like to do is use windows authentication but make the user enter thier windows password prior to logging into sql server. Is there a way? Thanks in Advance.
Kent
View 2 Replies
View Related
Oct 10, 2007
This is for SQL 2005 and I know how to right click an index and do a "script index as create to new query window"
Basically, the one of the Microsoft scripts or views will tell us that we have 100+ indexes that exist for a database but that they are not being used by SQL server.
I will probably take them "offline" for a while and then drop them later on.
Before dropping them, I would like to be able to recreate them within minutes if system performance is degraded after this happens.
I was working on a script to pull this info out of the sys. tables like below but was wondering if anyone already has a script or an easier way to do this. (...and I don't want to right click 100 indexes within 137 tables and script to a new window and then compile a big script)
SELECT
'Create ' +
i.type_desc COLLATE SQL_Latin1_General_CP1_CI_AS +
' Index [' +
i.name +
'] ON ' +
t.name +
CHAR(10) +
c.name +
' ASC'
FROM sys.index_columns ic
Join sys.indexes i ON i.index_id = ic.index_id
JOIN sys.tables t ON ic.object_id = t.object_id
Join sys.columns c ON ic.column_id = c.column_id
WHERE
i.name = 'IX_Sellers_StatusID' and
c.object_id = t.object_id and
i.object_id = ic.object_id
Thanks,
Brian
View 3 Replies
View Related
Mar 28, 2006
I have a text file I need to zip (compress) before uploading it via an FTP task. Do I have to use a third-party tool to do this? Thanks.
View 15 Replies
View Related
Apr 16, 2014
I have to create a report and I want all activity for the previous month.
I need to calculate the First and Last Day Prior Month to be used as Input Parameters.
Would something like this be the case or is there a better solution?
[code="sql"]
SELECT DATEADD(month, DATEDIFF(month, -1, getdate()) - 2, 0) as FirstDayPreviousMonthWithTimeStamp,
DATEADD(ss, -1, DATEADD(month, DATEDIFF(month, 0, getdate()), 0)) as LastDayPreviousMonthWithTimeStamp
[/code]
I was thinking get the first day of the previous and current month to exclude the Timestamp and use a less then first day of current month?
View 3 Replies
View Related
Aug 11, 2015
I have a situation where our stored procedure inserts records from table_1 to table_2 when they don't already exist (uses the EXIST statement) on that table. If table_1 contains multiple records that are the same, it appears after the 1st record has been inserted, it does not recognize it as being there when it checks the existence when attempting to insert record 2.
Here's an example of the script:
insert into table_2 (col1,col2,col3)
select col1,col2,col3
from table_1 t1
where not exists (select '1'
from table_2 t2
where t1.col1 = t2.col1
and t1.col2 = t2.col2
and t1.col3 = t2.col3)
Data from Table_1 -- Assume that table_2 does not contain these records
col1 col2 col3
AA 11 A1
AA 11 A1
BB 22 B2
All 3 records would be inserted to table_2 in this example.
View 7 Replies
View Related
Apr 25, 2015
We were asked to fix a query to get rows from a prior year history table that did not match to rows in the current year to show a variance from one year to the next. Rows must match on [corpnbr],[plincd],[pgrpcd] and [pitmcd]. If the combination has rows in the current and prior year ([hstyr]) then everything is fine. However, if they have rows in the prior year (e.g. [hstyr]='2014') but not in the current year (e.g. [hstyr]='2015') then they do not show in the result. Below is how they designed the table and below that is the stored procedure to pull the records.
CREATE TABLE [dbo].[BillingHistory](
[BillingHistoryID] [int] IDENTITY(1,1) NOT NULL,
[entity] [varchar](4) NULL,
[plincd] [varchar](3) NULL,
[pgrpcd] [varchar](4) NULL,
[pitmcd] [varchar](4) NULL,
[newplincd] [varchar](2) NULL,
[Code] ....
View 13 Replies
View Related
Dec 5, 2007
Hello ,
I'm facing a complicated problem and I don't think that the solution will be an easy one.
I have an SQL statement in Oracle which I need to translate it in Sql Server 2005.
select lpad(' ',5*(orderid)) || to_char(descr) as menui
from <table _name>
where MENU_ITEM not in ('test1','test2','test3') and item_parent not in ('test4,'test5,'test6')
start with <item_parent='item_parent' >
connect by prior <menu_item = item_parent and menu_name='ADR_m_adr_frame'; > ?(condition)
Somewhere I have read that SQL server does not support Hierarchical Sql statements. Is this true ? How am I going to do that ?
Any help will be appreciated.
Thank you
View 7 Replies
View Related
Aug 23, 2007
Hello folks,
I am trying to set up replication between a central office and multiple sites. This will be merge repl, since either central or satellites can be modified. However, one issue I ran into is setting up subscribers. I don't always have the option of starting with a publisher's snapshot; some of the subscribers have their own data already, which may or may not overlap with central site, and which needs to be synchronized into the central site somehow.
So far, I haven't seen any solution for this kind of scenario, at least nothing out of the box. Am I doomed to having to roll out custom data transfers (I don't think I can use DTS since all sites are running Express), or is there some standard way of doing this?
Thanks so much!
Sonya
View 6 Replies
View Related