Invalid Date Filtering

May 31, 2007

Hi,

There is a date field present in table1 as character field in the format of YYYYMMDD. I need to convert this to datetime
and load it into table2. But there are some invalid dates in that field of table1.While converting and loading to table2 i need to put NULLS for the invalid dates and continue loading the rest of them into table2.

Eg: Dates in Table1:
19860930,
0,
999,
19820925 etc.

When i load into table2 it should be loaded as
1986-09-30 00:00:00.000
NULL,
NULL,
1982-09-25 00:00:00.000

How can i add this conditon to the query. Currently i have the below selection query:

SELECT CAST(LTRIM(RTRIM(ODRDT)) as datetime) AS ORDERDT
FROM Table1

Please advise

Thanks,

View 9 Replies


ADVERTISEMENT

SQL Query Filtering Date Field By Today's Date?

Nov 3, 2006

Can someone tell me sql query for filtering date field for current day,not last 24hours but from 00:00 to current time?

View 2 Replies View Related

Filtering By Date

Mar 19, 2007

Please can someone assist me which this simple query:

Im using MSSQL Server 2005:

select * from ex_messagelog where DateCreated = '2007-03-19'

The query above does not return any results, but my data looks as follow: Note, the DateCreated is a DATETIME Datatype field.

239test 2007-03-19 08:42:19.00000
240Hallo Frank2007-03-19 08:45:43.00000
241spring 123 2007-03-19 08:49:41.00000
242testing 1232007-03-19 08:51:15.00000
243testing 1232007-03-19 08:52:39.00000
244as 2007-03-19 08:55:30.00040

View 4 Replies View Related

Filtering By Date

Jun 13, 2008

Hello I am trying to gilter a table by getdate() (i also tried now()) but I cannot seem to be able to do it I place my code below if anyone can help. am grateful, my db is sql 2005.



<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = getdate()
If (Request("MM_EmptyValue") <> "") Then
Recordset1__MMColParam = Request("MM_EmptyValue")
End If
%>
<%
Dim Recordset1
Dim Recordset1_cmd
Dim Recordset1_numRows

Set Recordset1_cmd = Server.CreateObject ("ADODB.Command")
Recordset1_cmd.ActiveConnection = MM_connpeepeek_STRING
Recordset1_cmd.CommandText = "SELECT usr_image1, dateimage_usr FROM diddle.ps_usr_image WHERE dateimage_usr = ?"
Recordset1_cmd.Prepared = true
Recordset1_cmd.Parameters.Append Recordset1_cmd.CreateParameter("param1", 135, 1, -1, Recordset1__MMColParam) ' adDBTimeStamp

Set Recordset1 = Recordset1_cmd.Execute
Recordset1_numRows = 0
%>

if any one can help I would be grateful

k

View 11 Replies View Related

Filtering By Date

Dec 12, 2007

I have a View with a structure like this

VisitTimes Company
2007-07-10 14:24:38.000 Microsoft
2007-03-10 11:14:38.000 Microsoft
2007-12-01 13:04:56.000 SQLTeam
2007-12-13 12:54:52.000 GoldMan Sac
2007-08-11 02:15:38.000 Oracle
2007-02-11 12:45:04.000 SAP Ltd

I am asked to write a stored procedure that get a count of each count of visit on a START and END date
I wrote the below SP but am not getting the right result
I think the **where VisitTime >= @Start AND VisitTime <= @End)** is not being evaluated. Help pls

CREATE procedure dbo.GetVisits
@Start varchar(50),
@End varchar(50)
as
SELECT TOP 100 PERCENT COUNT(company) AS VisitCount, company
FROM visits.dbo.IViewVisits where EXISTS
(SELECT * FROM VISITS.dbo.IViewVisits where VisitTime >= @Start AND VisitTime <= @End)
GROUP BY company ORDER BY COMPANY ASC

View 6 Replies View Related

Filtering By Date On A Chart

Mar 3, 2007

Hi all,

I have a datasource with three columns.

NAME / DATE / COST

The dates run from January 2005 to March 2007.

They appear in the following format in the query window:

03/01/2005 00:00:00

All I want to do is put the dataset in to a graph and filter the date so it only shows any cost from January 2006 onwards. What ever date I type in the filter I get the following error

"Cannot compare date of types System.Datetime and System.String"

Anyone know what I am doing wrong or how to solve the problem?

Cheers,

Rob.

View 1 Replies View Related

Filtering Sql Report By Date

Mar 18, 2008


We are pulling data from a sharepoint list and we have created a report using business development studio in sql 2005 and have created a table with data that we want to display.
We are trying to filter this data so that we can get the report to show entries for the day or for a week, but im not sure how to achieve this?
Thanks in advance.

View 28 Replies View Related

Date Criteria In View Not Filtering

Mar 19, 2007

I am using BETWEEN '02/01/2007' AND '2/01/2006' in the criteria of a VIEW and have tried <= '02/01/2007' AND >='2/01/2006' but both are not filtering the dates correctly. Is there another way? What am I missing?

View 4 Replies View Related

Filtering Most Recent Date Using Ssis

Nov 5, 2007



Hi I have a issue here where i have to store a record from a flat file into Sql Server Table.

The criteria is that there are records in flatfile having same business key but different transaction dates.

I have to place only htose records into the table which are having recent or greater transaction date .

example

name age date
xyx 34 00000000
xyx 34 20071103
xyx 34 20071031


key age and Name

ihave to pick only one record with greater o recent date from 3.


What approach should i take.

Some of the Business keys conssit of 2 or 3 columns .

I have to insert or store only the recent Date consisting records. how do i acheive this please help me.

View 13 Replies View Related

Filtering By Date Range - Want To Aggregate

Jun 19, 2007

Im trying to get the top 10 sales people by date range



my cutdown select statement for my dataset is as follows:


SELECT TOP 20 SaleDate,Consultant, State, Sum(Value) As Winbacks, UserID

FROM dbo.tbl_kpi_sales
GROUP BY Consultant, State, SaleDate, UserID
HAVING (SaleDate)>= @Param_StartDate and (sales.SaleDate)<= @Param_EndDate) AND State IN (@Param_State)
ORDER BY Winbacks Desc;



The problem im getting is that when a date range is entered by the user, the same representative might appear in the top 20 list afew times as they made the top sale for different days, I am wanting the select statement to add up the total sales for that representative for that date range and return him as a single entry...Because the sale date is in the select statement the group by clause separates these records, I cannot take the sale date out off the select because i need it to determine the date parameter for the reports



for example for date range - 1/3/2005 to 20/3/2005 get the top 20 reps Im currently getting



Name Value Date

Jim Brown 20 1/3/2005

Jim Brown 10 12/3/2005

Jim Brown 23 13/3/2005

Tom 10 12/3/2005

etc...till top 20



I am wanting the following output



Name Value

Jim Brown 53

Tom 10



Is there someway off doing this which still allows me to use a date range entered into report services





View 3 Replies View Related

Filtering On Parts Of A Date/time Field

Jan 3, 2007

Hi,I have a date/time field in a SQL2000 database, and what I would liketo do is to filter on a specific part of the field, for example thetime or hour.Supposing I have a set of data for the last 5 years and would like tofilter out any records which are outside working hours i.e. I wouldlike to show records where the time is between 9am and 5pm.Does anyone know if there is a simple way to do this in SQL? If yousimply don't specify the date part in the where clause (e.g. WHEREissuedatetime between '09:00:00' and '17:00:00') it defaults it to1900-01-01 so basically no data is returned.The only way I can see to do this is by using the DATEPART function,converting it to a varchar, appending 1900-01-01 on to it andconverting it to a datetime, and then using the where clause as statedabove. This is quite a long-winded way, however. Any other suggestions?Thanks,Matt

View 3 Replies View Related

Power Pivot :: Date Fields Do Not Allow Value Filtering

Sep 8, 2015

I have an Excel 2010 Pro pivot table that uses a Power Pivot view sourced to a SQL Server 2012 SQL view.  This view contains multiple date fields, and when I attempt to use the 'Value Filter' on one of these, the data is not filtering.  The data type in the SQL view is a date.

After attempting to set a Value Filter, and seeing that the filtering didn't work, when I go back to the Value Filter criteria (in my case, I used 'Greater Than' option), the date value that I plugged in to filter has been replaced with a numeric value.

View 3 Replies View Related

Transact SQL :: Filtering Join Tables By Date

Sep 14, 2015

I need to Filter Employees by Available Date and grab their Basic contact information

I used Join to Join both tables  but I can't seem to find a way to only get data from employees where DateAv > SelectedDate.

I'm using this in a SqlCommand with C#. 

SELECT " EmployeeNameTable.ID, EmployeeNameTable.FullName, EmployeeNameTable.DateAV,ContactTable.HomePhone, ContactTable.MobilePhone, ContactTable.Email FROM EmployeeNameTable INNER JOIN ContactTable On EmployeeNameTable.ID = ContactTable.ID OrderBy EmployeeNameTable.FullName"

This code loads all employees Successfully but it doesn't filter them by the DateAV Column which is in Date Format.

View 2 Replies View Related

Correlated Subquery And Date Filtering Problem

Oct 6, 2006

Note the following sql query. It contains two separate queries, an correlated subquery and outer query to work against the results of the subquery. Its purpose is twofold (1) get the TOP n ranked field entities using a certain value, (2) return all records for those entities.

SELECT MasterLoanID, NoteNumber, LendingOfficer,OriginalAmount, ReviewSampling FROM MasterLoanData WHERE Import_AsOfDate = '2006-05-31' AND BankID = '1' AND clientID = 1 AND LendingOfficer IN(SELECT TOP 3 LendingOfficer FROM MasterLoanData WHERE Import_AsofDate = '2006-05-31' AND ClientID = 1 AND BankID = '1' GROUP BY LendingOfficer ORDER BY SUM(OriginalAmount) DESC) ORDER BY LendingOfficer, Notenumber

Note that both queries need to filter the same fields -- import_AsofDate, BankID, and ClientID -- in order produce accurate results. Separate indexes exist for all three fields. Both queries work against the Sql Express database, however, when I combine them in a sql statement, Sql Express seems totally lost -- the query runs but never finishes -- I have to abort execution!

I've isolated the problem down to referencing of the import_AsofDate field in the outer query WHERE clause. If I remove that field reference from the outer WHERE clause, the query works quickly -- in seconds, however the results aren't accurate because I'm not getting a filter against the correct Import_AsofDate value. Note too that the same Access database executes the same query in seconds! Sql Express just seems totally confused by date reference contained in both WHERE clauses. I'd say that signifies a definite problem in Sql Express.

Has anyone experienced a similar problem with a correlated subquery and the same date field being referenced in both WHERE clauses of each query? I don't currently have a full fledged Sql Server database to test this query against, but seems as though it should work.

Rick

View 7 Replies View Related

Access Crashes Filtering A Linked SQL Table On A Date Field

Jun 29, 2006

I have an MS Access 2002 application that is distributed to a number of PCs around our office. The data for this application is stored on a central SQL Server that is linked in through ODBC.

This application has been in place for two years and working fine. We recently formatted and restored a PC, and now that particular PC has issues with the Access application.

Every time it tries to filter one of the linked SQL tables on a date field, Access goes unresponsive and GPFs out. If it's in a query that is behind a report, I get the old standard 'Catastrophic Failure'. If I open the table and right-click filter or run a query manually, Access GPFs.

I've tried recreating the ODBC, linking the tables through TCP/IP as well as Named Pipes. Nothing fixes it. All Windows and Office updates have been applied. This is not the first time we've reformatted a PC in the office, but we've never had this issue.

Has anyone run across this before?

Thanks!

-Ben

View 1 Replies View Related

SQL Reporting Services 2005: Filtering Tables By Date And Time

Feb 19, 2008

I am trying to generate a report that is basically a class list. It lists classes for a specific semester and lists them by day of the week and then by time.

If I am pulling back a dataset of all classes, how do I filter my report so as to show each set of classes appropriately (by day and by time within the day)? I tried using the Filter function on the table level, but I guess I don't get it.

My table would need to look like this:



MONDAY:



8:30 - 9:30
9:30- 11:30
11:30-1:30

classnum/prof
classnum/prof
classnum/prof

classnum/prof
classnum/prof
classnum/prof


TUESDAY:




8:30 - 9:30
9:30- 11:30
11:30-1:30

classnum/prof
classnum/prof
classnum/prof

classnum/prof
classnum/prof
classnum/prof

View 4 Replies View Related

SQL Server 2014 :: Indexes And Views - Manage Date Filtering Within A Query?

May 21, 2014

I have a dynamic SQL query that uses various indexes and views.

When a user wants to filter records based on last one day, last one week, last 30 days ...etc.. i use the following code:

@date is an integer.

begindate is datetime format.

begindate > cast(((select dateadd(d,@Date,GETDATE()))) as varchar(20))

The above code slows my query performance by at least 400%!

Would it be faster to add a computed column to my table, using the suggested method in the link below?

[URL] ....

Then i could add an indexed view to improve performance, or can this be done another way?

View 9 Replies View Related

Invalid Date Format

Oct 26, 2007



I am exporting data from Oracle to SQL server using SSIS package, I see some invalid date in the orcale tables. I am trying to redirecting them to different output table. But I am getting the following error.

Error: An OLE DB error has occurred. Error code: 0x80004005. An OLE DB record is available. Source: "Microsoft OLE DB Provider for SQL Server" Hresult: 0x80004005 Description: "Invalid date format".

Can any one know how to filter these invalid values?

Thank you,
Dathendra

View 1 Replies View Related

Invalid Date Format Error ... Please Help ...

May 2, 2002

Hi,

I'm using ODBC (System DSN) to connect to SQL Server 7.0 Database.
Whenever I try to connect to SQL Server Database from my client
application, I'm getting the following error message -

----------------------------------------------------------
Microsoft SQL Server has reported the following error:

[Microsoft] [ODBC SQL Server Driver] Invalid Date format
----------------------------------------------------------


After this message, I'm getting another error message -

----------------------------------------------------------

Cannot create a record in table SysConfig (SysConfig).
The SQL Database has issued an error.

----------------------------------------------------------

Subsequently, I get another error message -

-----------------------------------------------------
[Microsoft][ODBC SQL Server Driver]Invalid date format [INSERT INTO SYSCONFIG

(CONFIGTYPE,ID,VALUE,MODIFIEDDATE,MODIFIEDTIME,MOD IFIEDBY,CREATEDDATE,CREATEDTIME,CREATEDBY,RECID

) VALUES (?,?,?,?,?,?,?,?,?,?)]
-----------------------------------------------------

The application that I'm trying to connect from is a package from 3rd
Party. I do not have any control over it.

But I think the problem could be from the side of SQL Server. Can someone
look into this please?

Thanks,
Harish

View 1 Replies View Related

SQLDescribeParam With Subselect: Invalid Parameter Number/Invalid Descriptor Index

Apr 21, 2008

Hello,

I've got the following query:

SELECT zA."ID" AS fA_A
, zA."TEXT" AS fA_B
, (
SELECT COUNT(zC."ID")
FROM Test."Booking" AS zC
) AS fA_E
FROM Test."Stack" AS zA
WHERE zA."ID" = ?

With this query I call:
- SQLPrepare -> SQL_SUCCESS=0
- SQLNumParams -> SQL_SUCCESS=0, pcpar = 1
- SQLDescribeParam( 1 ) -> SQL_ERROR=-1, [Microsoft][ODBC SQL Server Driver]Invalid parameter number", "[Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index"

Is there a problem with this calling sequence or this query? Or is this a problem of SQL Server?

Regards
Markus

View 7 Replies View Related

Error While Converting Oracle Timestamp To Sql Server Timestamp (datetime) - Invalid Date Format

Jun 19, 2007

I am populating oracle source in Sql Server Destination. after few rows it fails it displays this error:

[OLE DB Destination [16]] Error: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005. An OLE DB record is available. Source: "Microsoft OLE DB Provider for SQL Server" Hresult: 0x80004005 Description:
"Invalid date format".



I used this script component using the following code in between the adapters, However after 9,500 rows it failed again giving the same above error:








To convert Oracle timestamp to Sql Server timestamp

If Row.CALCULATEDETADATECUST_IsNull = False Then

If IsDate(DateSerial(Row.CALCULATEDETADATECUST.Year, Row.CALCULATEDETADATECUST.Month, Row.CALCULATEDETADATECUST.Day)) Then

dt = Row.CALCULATEDETADATECUST

Row.CALCULATEDETADATECUSTD = dt

End If

End If



I don't know if my code is right . Please inform, how i can achieve this.

View 6 Replies View Related

Need Help Filtering

Apr 18, 2007

I need help with filtering a specific set of numbers.  I have a Sql database that is connected to my sql report I have created a tsql statement that pulls a clients name, PO, and invoice number. The prblem I am having is I have 2 different types of invoice numbers  one number looks like 123456-1234-T the other looks like 123455-1234-L I need to beable to pull only the invoices with T on one report and L on another report  can some on show me how I can sort these in a tsql script

View 8 Replies View Related

Help With Filtering

Aug 29, 2006

I have table with the following columns.

ID, DearlershipLocation, VehicalMake, VColor, VType, VYear

1, London, Buick, Red, Sedan, 2000

2,

2006, Windsor, Ford, Blue, Jeep, 2002

My question is, how do I write a query to filter fron all Dealership location a speciif car like Ford with a red color and a sedan type?

Please help.

Thanks.

Juvan

View 1 Replies View Related

Sum By Filtering

Apr 4, 2008

Hello,

This may be simple, but I can't figure a way to do this. I have the following data returned to a table and need to sum only the items where HDMethod=0 in the table footer. For some reason, something like:

=Sum(Iif(Fields!HDMethod.Value=0, Fields!BDExtended.Value, Nothing)) returns all the rows.
There is a LEFT OUTER JOIN: dbo.[Billing Detail].Item = dbo.[History Detail].Item between the tables touched in the query if that helps.

Thanks for any help you can offer.
:

BDBilling BDExtended HDMethod BDDate
----------- --------------------- -------- -----------
14965 30.00 0 2008-03-24
14965 25.00 NULL 2008-03-24
14965 28.00 NULL 2008-03-24
14965 45.00 NULL 2008-03-24
14966 30.00 0 2008-03-24
14966 50.00 NULL 2008-03-24
14966 20.00 NULL 2008-03-24
14966 45.00 NULL 2008-03-24
14966 42.00 NULL 2008-03-24
14966 60.00 NULL 2008-03-24
14967 30.00 0 2008-03-24
14967 25.00 NULL 2008-03-24
14967 28.00 NULL 2008-03-24
14967 45.00 NULL 2008-03-24
14968 30.00 0 2008-03-24
14968 25.00 NULL 2008-03-24
14968 28.00 NULL 2008-03-24
14968 45.00 NULL 2008-03-24
14969 30.00 0 2008-03-24
14969 25.00 NULL 2008-03-24
14969 28.00 NULL 2008-03-24
14969 45.00 NULL 2008-03-24
14969 42.00 NULL 2008-03-24
14969 60.00 NULL 2008-03-24
14970 30.00 0 2008-03-24
14970 25.00 0 2008-03-24
14970 28.00 0 2008-03-24
14970 45.00 0 2008-03-24
14970 60.00 0 2008-03-24

View 3 Replies View Related

Help With Filtering

Aug 29, 2006

I have a table with the following columns

ID, Dealershiplocation, VehicalMake, VColor, Vtype and VYear.

1, London, Buick, Red, sedan, 2001

------

20, Windsor, Ford, Blue, pickup, 2004

My question is how do I write a query so I can filter from all dealership location a specific vehical like

Ford with a red color and Sedan type?



Please help.

Thanks

Juvan

View 3 Replies View Related

How To Use Convert Date Statement In CmdInsert.Parameters.Add(Date,SqlDbType.DateTime).Value = Date

Sep 21, 2006

HiI am using SQL 2005, VB 2005I am trying to insert a record using parameters using the following code as per MotLey suggestion and it works finestring insertSQL; insertSQL = "INSERT INTO Issue(ProjectID, TypeofEntryID, PriorityID ,Title, Area) VALUES (@ProjectID, @TypeofEntryID, @PriorityID ,@Title, @Area)"; cmdInsert SqlCommand; cmdInsert=new SqlCommand(insertSQL,conn); cmdInsert.Parameters.Add("@ProjectID",SqlDbType.Varchar).Value=ProjectID.Text; My query is how to detail with dates my previous code wasinsertSQL += "convert(datetime,'" + DateTime.Now.ToString("dd/MM/yy") + "',3), '";I tried the code below but the record doesn't save?string date = DateTime.Now.ToString("dd/MM/yy"); insertSQL = "INSERT INTO WorkFlow(IssueID, TaskID, TaskDone, Date ,StaffID) VALUES (@IDIssue, @IDTask, @TaskDone, convert(DateTime,@Date,3),@IDStaff)"; cmdInsert.Parameters.Add("IDIssue", SqlDbType.Int).Value = IDIssue.ToString();cmdInsert.Parameters.Add("IDTask",SqlDbType.Int).Value = IDTask.Text;cmdInsert.Parameters.Add("TaskDone",SqlDbType.VarChar).Value = TaskDoneTxtbox.Text;cmdInsert.Parameters.Add("Date",SqlDbType.DateTime).Value = date;cmdInsert.Parameters.Add("IDStaff",SqlDbType.Int).Value = IDStaff.Text;Could someone point to me in the right direction?Thanks in advance

View 3 Replies View Related

SqlDataSource And Filtering

Aug 3, 2006

Hi All,
I have following:

a text input for filtering
a gridview that displays the data
an SqlDataSource that contains the query.
Users can either enter something into the text input or leave it blank. Depending on that, the gridview should either display all data (unfiltered, because nothing was entered into the text field) or filtered data (when something is entered).
Now my problem is in defining the query in the SqlDataSource. I could do something like this:
SELECT * FROM myTable WHERE myField = @p1;
and then add in the appropriate <asp:ControlParameter /> under the <SelectParameters> tag. However, this sorta "fixes" the filter. Regardless of whether users actually type something in or not, the filter is in effect. I want it in such a way that if users do not type in anything, the query essentially becomes:
SELECT * FROM myTable;
Is there any way to achieve this?
Thanks in advance,
jason

View 5 Replies View Related

Filtering Values

Apr 1, 2008

does anyone one know how to filter this 01/23/2008 to 2008. i just want the year and stored it to a column in my sql database.
 
thanks

View 3 Replies View Related

Row_Number Filtering

Jun 20, 2008

I'm not sure if this is possible and have been having trouble figuring out the code to do this.  I am assigning row_number to a gridview.  I then want to filter the results with a dropdown.  I am able to get the filter to filter the status but it either renumbers the gridview or it leaves the row numbers blank.  Is there a way to have the row_numbers stick to the gridview when I filter?  Example below.  Thanks
Normal:IssueNumber(row_number), Status1, Open2, Open3, Closed4, Open5, Closed
"Open" Filter:IssueNumber(row_number), Status1, Open2, Open4, Open
"Closed" Filter:IssueNumber(row_number), Status3, Closed5, Closed

View 4 Replies View Related

Help On Filtering Data

Nov 9, 2004

Why is Select * from [Merchandise] where [Product Name] like '[ABCD]%'the same as Select * from [Merchandise] where [Product Name] between 'A' and 'D'I can run Select * from [Merchandise] where [Product Name] like 'A%'and get Products that start with the letter "A" but they don't show up when I try to get all "A","B","C","D" Products.

View 2 Replies View Related

2.0: SqlDataSource Filtering

Mar 27, 2006

I think I might be missing something here.
Here is what I'd like to do:1. Retrieve a list of data from SQL Server.2. Display that data in a gridview.3. Have the user click on a button to then see a subset of that data. (filtering)
I can't seem to make this work.  When the user clicks the button,  I need the GridView to update to show only the specified data.  In 1.1 I would created a DataView for the filtering, but am trying to use the latest and greatest. 
I've seen examples online of people using DropDownLists to act as the dynamic filter parameter.  How can I programatically assign this to make it work?Thanks!

View 1 Replies View Related

Filtering Data

Nov 13, 2001

Hi,

Our current method of limiting what data a user can see is implemented solely through our Web based business intelligence tools. No filtering is enabled at the database level. This has become somewhat cumbersome as security is tied exclusively to these tools. The tools use one common logon to access the underlying database.

I would like to implement security at the database level (SQL Server 2000) and thereby produce a more flexible/portable solution. I was thinking of setting up individual database accounts for each user and then tying these into our company structure table by passing system_user result to a constraint.

For example System User name 'Store 2' would reference Store '2' in the structure table. Depending on the user, different columns will need to be referenced to filter the rows. A store user would be validated against the store column, an Area Manager user would be validated against the Area Manager column and Head Office users would not be valiadated at all i.e. they are not filtered.

1) What is the best method to implement such a look up. Can or should I use Check constraints for such a solution?

2) Would a UDF be useful?

Any ideas on the best approach to take would be greatly appereciated.

Thanks

Rob

View 1 Replies View Related

Comparing And Filtering??

Sep 1, 2003

Hello all,

I'm new to SQL Server so if the following sounds stupid then apologies. I am trying to design a query which compares columns and filters according to the result of the comparison. We are a UK based charity that provides financial help to families with disabled children (www.familyfund.org.uk). We have a large database (250,000 entries) which we know contains some duplicate/split files from a recent migration. We need to identify these files but not delete them. Currently I am using the following:

SELECT dbo.Families.famId, dbo.Address.street, dbo.Children.childId, dbo.Address.postcode
FROM dbo.Children INNER JOIN
dbo.Families ON dbo.Children.family_no = dbo.Families.famId INNER JOIN
dbo.Persons ON dbo.Families.famId = dbo.Persons.famId INNER JOIN
dbo.Address ON dbo.Persons.addressId = dbo.Address.addressId
WHERE (NOT (dbo.Children.eligStatus IN (3, 4)))
GROUP BY dbo.Children.childId, dbo.Address.postcode, dbo.Families.famId, dbo.Address.street
HAVING (dbo.Address.street IS NOT NULL)
ORDER BY dbo.Address.street

Obviously this returns all 250,000 records and then we have to search manually. We would like to run a query which compares families.famID to address.street so that where famId has more than one address attched it is returned to the results grid. Does this make sense? is it possible? Any help would be gratefully received

Thanks in advance
Mark
:confused:

View 8 Replies View Related







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