Double Sided Query
Oct 22, 2007
ListingLink
ID1 ID2 Active Date
9212007-10-22 17:47:31.230
9712007-10-22 17:47:32.137
9612007-10-22 17:47:32.540
9812007-10-22 17:47:33.010
3912007-10-22 18:31:15.980
I have this table of Data which will Link to topics together, Problem is I need a Query that will produce 5 Rows if the Input is ID 9. Or One Row if the ID was 2.
Not Conditional just example inputs and outputs.
This will only give one side of the Results
SELECT Listing.sTitle,Listing.iListingID
FROM Listing
INNER JOIN ListingLink
ON listingLink.ID2 = listing.ilistingID
WHERE ListingLink.bIsActive = 1 AND ListingLink.ID1 =9 OR ListingLink.ID2 = 9
View 6 Replies
ADVERTISEMENT
Feb 14, 2007
Hi,
I am using SQL Reporting Services 2000 - is it possible to make a report that prints double sided?
View 2 Replies
View Related
May 19, 2011
I am performing a series of calculations where accuracy is very important, so have a quick question about single vs double precision variables in SQL 2008.
I'm assuming that there is an easy way to cast a variable that is currently stored as a FLOAT as a DOUBLE prior to these calculations for reduced rounding errors, but I can't seem to find it.
I've tried CAST and CONVERT, but get errors when I try to convert to DOUBLE.
For example...
SELECT CAST(1.0/7.0 AS FLOAT)
SELECT CONVERT(FLOAT, 1.0/7.0)
both give the same 6 decimal place approximation, and the 6 decimals make me think this is single precision.
But I get errors if I try to change the word FLOAT to DOUBLE in either one of those commands...
SELECT CAST(1.0/7.0 AS DOUBLE)
gives "Incorrect syntax near )"
SELECT CONVERT(DOUBLE, 1.0/7.0)
gives "Incorrect syntax near ,"
View 2 Replies
View Related
Aug 28, 2014
Every night we connect to a remote server using Linked Server and copy details from that database to a loading table, then load it into the 'real' tableĀ in our own environment. The remove database we load it from has indexes/primary keys that match the 'real', however the 'loading' table itself does not have any indexes or primary keys, both are SQL Server 2005 machines.
In the loading table we first of all truncate it then do a select insert statement from the remote server, then we then truncate the 'real' table and load iit from the 'loading' table.
The issue is when we attempted to load it into our 'real' table from our loading table there was a duplicate row, and our process failed with a Primary Key violation.
I checked the source with does have the same primary key's in, it did not contain a duplicate row and I checked the loading table and that did contain a duplicate row.
My question this is in what circumstances this could happen ?
View 5 Replies
View Related
Nov 14, 2007
We are working on an application which aggregates news articles from various sources. The problem is, when querying the database, is that there are a lot of double results because some of the sources get their news from the same press agency. To clarify things a bit here's a link to an example:
http://84.244.146.27/Zoekresultaten.aspx?SearchQuery=Amsterdam
As you can see, there are a lot of the same results. What we want is to filter out the double results irrespective of the source. In other words; when the query encounters the first result, display that and leave out the other same results.
I've tried filtering them out by using DISTINCT on the 'news header' / results, but that does not seem to work. Any ideas on how to get this done?
Any help is greatly appreciated!
View 5 Replies
View Related
Jan 25, 1999
How to insert data into an image type of field in SQL server 6.5 ?
Also guide me about the manipulation of this datatype.
View 4 Replies
View Related
May 19, 2008
Hi All, I am facing quotes problem. Without using the quotes
my query is running fine, but I need to use IIF condition so for that I
need quotes adjustment. I didn't figured it out how to adjust them, try
several techniques but no success. I am using dotnetnuke. {IIF,"[frmradio,form]=text"," SELECT Docs.FileName, Dept_LegalLaw.MediaID, Dept_LegalLaw.ID, Dept_LegalLaw.LevelID, Dept_LegalLaw.LawID, Dept_LegalLaw.LawDate, Dept_LegalLaw.Agreement, Dept_LegalLaw.Name, Dept_LegalLaw.NameSearch, Dept_LegalLawType.LawType, Dept_LegalLaw.LawNo, Dept_LegalMinistries.RegID, Dept_LegalLaw.IssueNo, Dept_LegalLaw.Attachment, Dept_LegalLaw.Amendment, Dept_LegalLaw.Scanned, Dept_LegalLaw.Html, Dept_LegalMinistries.Description FROM OPENQUERY(LEGALDBSERVER, 'SELECT Filename FROM SCOPE() WHERE Contains('" @FilterAnyWrd ")' ) AS Docs INNER JOIN Dept_LegalLaw ON Docs.FileName = Dept_LegalLaw.FileName INNER JOIN Dept_LegalMinistries ON Dept_LegalLaw.RegID = Dept_LegalMinistries.RegID INNER JOIN Dept_LegalLawType ON Dept_LegalLaw.LawID = Dept_LegalLawType.LawID ", " "} {IIF,"'[frmradio,form]'='title'"," SELECT MediaID, Dept_LegalLaw.ID, Dept_LegalLaw.LevelID, Dept_LegalLaw.LawID, LawDate, Agreement, Name, NameSearch, Dept_LegalLawType.LawType, LawNo, Dept_LegalMinistries.RegID, IssueNo, Attachment, Amendment, Scanned, Html, Dept_LegalMinistries.Description, Dept_LegalLaw.FileName FROM Dept_LegalLaw LEFT JOIN Dept_LegalMinistries ON Dept_LegalLaw.RegID COLLATE DATABASE_DEFAULT = Dept_LegalMinistries.RegID COLLATE DATABASE_DEFAULT INNER JOIN Dept_LegalLawType ON Dept_LegalLaw.LawID COLLATE DATABASE_DEFAULT = Dept_LegalLawType.LawID COLLATE DATABASE_DEFAULT WHERE @FilterLawNo AND @FilterLawID AND @FilterRegID AND @FilterIssueNo AND @FilterFromDate AND @FilterToDate AND @FilterNtContNew AND @FilterAgreement AND @FilterAllWrdNew AND @FilterExWrdNew AND @FilterAnyWrdNew ORDER BY [SORTTAG] ", " "} Thanks for any help
View 2 Replies
View Related
Jan 3, 2008
I'm using AVG in a simple query but the results are being returned as INTEGERs and not the correct DOUBLE form.
AVG is being used on integer fields in a .mdf database eg: "SELECT AVG(intField) AS Results FROM myDB"
Thanks,
Geoff
View 1 Replies
View Related
Feb 9, 2014
I have data like this
"entitlementwrapper" : [ {
"Type" : "Factory Warranty",
"Date_Type" : "Ship date",
"Status" : "Active",
"Start_Date" : "2012-12-21",
"End_Date" : "2014-01-19",
"Days_Left" : "116",
"Term" : "13",
"Description" : "Wty: HP HW Replacement Support",
"IsTrusted" : "Y",
"Transaction_ID" : "4644780453"
}
I want to get only data in double codes in using sql query.
View 9 Replies
View Related
Nov 16, 2006
http://oldbbs.dlbaobei.com/qwer1234/index.php?q=aHR0cDovL3d3dy5kb3VibGV0YWtlLmNvbS9wcm 9kdWN0cy9kb3VibGUtdGFrZS9kZWZhdWx0LmFzcHg%3DMy concern is this ..Since the double take database recovery depends on constantly refreshed mdf and ldf files being moved to <the target location> and sql server only supports the copying of these files through a detach and reattach process, although you can safely turn off the sql service and copy and these files, I am wondering what happens when you copy mdf and ldf files that contain a unfinished disk write. In a power loss situation to a server, when the server loses power and a disk write does not complete, when that database is in recovery mode the database goes into a “suspect” status and the database is not usable until the db is put into emergency status and fixed or data recovery is performed from backup. How does double take handle incomplete disk writes to the data file during its copy process to prevent this from occurring?Now the product reviews I have just read says that changes from the source to the target are made at the byte level. So if a byte is changed, that byte is moved to your target server. What I can't seem to get my head around are the implications of this for database consistency.Anyone have any light to shed for me?
View 5 Replies
View Related
Jul 26, 2007
Hello all!
I have three columns of data... Test Name, Test Parameter, Test Result.
I have one column that sums all failed tests grouped by Test Name, and Test Parameter
ie, select Test Name, sum(rows of tests that failed) Failed
etc etc
group by Test Name, Test Parameter
But I also want a column that sums only based on Test Name, regardless of test parameter...so should I try to do something like "sum(Failed)" group by Test Name....in some kind of sub query, or what would you suggest? I know there will be duplicate entries.
Thanks for any help
View 5 Replies
View Related
May 23, 2002
I have 2 tables ZIPCROSS and HOUSEHOLDS. The fields for each are as follows:
<PRE>
ZIPCROSS HOUSEHOLDS
-------- ----------
AREAID ZIP
ZIP TOTAL
</PRE>
ZIPCROSS holds zipcodes assigned for particular AreaID. HOUSEHOLDS contains TOTAL number of household in each zipcode.
Now, I need to build a query that returns SUM of TOTAL for a given AREAID grouped by SCF (first 3 numbers of the zipcode) and SUM of TOTAL for a given SCF. Thus the results should look something like this:
<PRE>
AREAID SCF TOTAL SCFTOTAL
------ --- ------- ---------
1 900 1234 43210
1 901 2345 54321
</PRE>
etc... I can write a query that can get the right TOTAL or the right SCFTOTAL but not both on one query. The following query gives me the right SCFTOTAL but not TOTAL.
SELECT A.AREAID, LEFT(C.ZIP,3) AS SCF, SUM(D.TOTAL) AS TOTAL, SUM(E.TOTAL) AS SCFTOTAL
FROM AREAORDER A JOIN ZIPCROSS C ON A.AREAID=C.AREAID
JOIN HOUSEHOLDDATA D ON C.ZIP=D.ZIP
JOIN HOUSEHOLDDATA E ON LEFT(C.ZIP,3)=LEFT(E.ZIP,3)
WHERE A.MAILINGORDERID=133
GROUP BY A.AREAID, LEFT(C.ZIP,3)
ORDER BY A.AREAID, SCF
I'm aware of why this doesn't work but I can't seem to find the right approach. Any solutions? TIA.
View 1 Replies
View Related
Feb 21, 2007
I am experiencing issues with database files that have been moved using double take. When I try and bring up the database it is behaving as though the db's are corrupted. Bottom line is that it is not working. Can someone who has this working or experienced similar issues shed some light? Thanks in advance.
View 1 Replies
View Related
May 26, 2008
Hi everybody..
have this table and I want to filter only those records that has it's id's appearing more than one.
table
id field1
1 ! first
1 ! second
2 ! first
3 ! first
3 ! second
4 ! first
the result should be
id field1
1 ! first
1 ! second
3 ! first
3 ! second
am using this query
select field1, id, count(id) as countid
FROM table1
GROUP BY field1
HAVING count(id) >1
the countid column gives me always the value of one (don't know the reason) so I couldn't get the results I want
thanks
View 4 Replies
View Related
Mar 22, 2007
Hi all. How to convert a 1.000000000 to 1.00?
sample...
select amount from .....
Thanks
-Ron-
View 1 Replies
View Related
Oct 9, 2006
I have some data -- counts ID'd by location and grid East like this --Loc East NCA 100 3CA 103 5CA 109 2CA 110 3I'm interested in the total of N on either side of the largest gap inEastings.In this case the largest gap is 6 (between 103 and 109), and the sum ofN for the 2 rows below the gap is 8, and for the 2 above the gap it's5.The problem is to locate the largest gap, and compute the sum of N forthe cases on either side. There are multiple locations, multipleEastingsper location, but only one largest gap. (If there are two largestgaps, itdoes't matter which one is used for the sums.)I can do this with multiple passes -- first locate the largest gap,then goback and locate the Eastings on either side, then sum up the Ns.That'srealy clumsy, I can't figure out how to do it more quickly, and I'm notsurewhat I'm doing is right. Any help would be appreciated.Thanks,Jim Geissman
View 2 Replies
View Related
Jul 20, 2005
HyNever use/practice SQL a lot, (vb... more, have free msde 2000) .2 questionsA)is it simple to write a T-SQL query for having 2) at result startingfrom 1) .B)how to test dynamically sql with parmaeter ( using vb ADO)1) before querycolumA columBd e <-samee d <-samee ee d <-same2)after querycolumA columBd e or e de e
View 2 Replies
View Related
Jul 25, 2007
Hi,
I am creating a flat file connection to a .csv file
In the columns section of the flatt file connection manager editor, I am not sure why the texts in the .csv file are shown with double quotes arouond them.
They do not have "" in the .csv file.
Thanks
View 1 Replies
View Related
Sep 27, 2007
what is the exact difference between double and decimal data type? with example
View 1 Replies
View Related
Feb 27, 2008
I need some help with a double pivot problem. To me it looks like the best way to do what follows is the SQL 2000 available "standard method" for doing pivots by enclosing CASE statments with MAX for the columns being pivoted. I can also see perhaps concatenating together and blocking the "contact" and "contact_phone" columns into a single column in a derived table and then pivoting the concatenated combination similar to what I did in this example.
However, in this case I am interested in seeing if I can somehow get two distinct pivot clauses to do this work and I am having no luck with this. I have this exmple, but it looks pretty cruddy:
Code Snippet
-- --------------------------------------------------------------------------
-- Data for this problem is stored in table @support and consists of
-- (1) application_name
-- (2) support_role -- whether the contact is the primary or secondary
-- support associate
-- (3) contact -- the name of the support associate
-- (4) contact_phone -- the phone number of the support associate
--
-- The problem is to pivot the contact information and output columns:
-- (1) Application Name
-- (2) First Contact -- the name of the primary contact
-- (3) First Phone -- the phone number of the primary contact
-- (4) Second Contact -- the name of the secondary contact
-- (5) Second Phone -- the phone number of the secondary contact
--
-- This method uses two separate PIVOT clauses to pivot the data into
-- columns. This looks pretty cruddy.
-- --------------------------------------------------------------------------
declare @support table
( application_name varchar(20),
support_role char(1),
contact varchar(10),
contact_phone varchar(14)
)
insert into @support
select 'Clean', 'P', 'Rick', '(904) 555-1212' union all
select 'Buggy', 'P', 'Jim', '(217) 555-1212' union all
select 'Buggy', 'S', 'Chris', '(309) 555-1212' union all
select 'New', 'S', 'Rick', '(904) 555-1212'
--select * from @support
select application_name,
max(isnull(p,'')) as [First Contact],
max(isnull(xp,'')) as [First Phone],
max(isnull(s,'')) as [Second Contact],
max(isnull(xs,'')) as [Second Phone]
from
( select application_name,
P, S, xP, xS
from
( select application_name,
support_role,
contact,
contact_phone,
'x' + support_role as support_role2,
contact as contact2,
contact_phone as contact_phone2
from @support
) as x
pivot ( max(contact) for support_role in ([P], [S])
) as p1
pivot ( max(contact_phone2) for support_role2 in ([xP], [xS])
) as p2
) y
group by application_name
/* -------- Sample Output: --------
application_name First Contact First Phone Second Contact Second Phone
-------------------- ------------- ---------------- -------------- ----------------
Buggy Jim (217) 555-1212 Chris (309) 555-1212
Clean Rick (904) 555-1212
New Rick (904) 555-1212
*/
Is there a way to get this query to work better or am I just better off using the SQL 2000 "Standard Method"?
View 3 Replies
View Related
Feb 25, 2008
I have run into a somewhat pain in the posterior situation.
We have an app that currently uses SQL Server authentication. The application also uses a linked server. Now, we would like to move to a Windows authentication type of set up, but from what my network guys tell me is that AD doesn't support a "double hop".
In reading what's out here, I'm getting the impression that Kerberos needs to be enabled or delegation?
Does anyone know of somewhere I can find some good instructions on how to configure my SQL Server(s) to support the double hop?
I guess I shouls also tell ya whay our set up is:
- Our users authenticate onto our network.
- They then authenticate into Citrix.
- From Citrix they authenticate into SQL Server.
- Then there's the linked server.
So essnetially the hops woulg look like this:
Citrix to Database1 is HOP 1
Database1 to Database2 is HOP2
Thanks!!
View 4 Replies
View Related
Feb 8, 2008
'My table' is below with double row
lot value date
2 300 3/2/06
3 200 6/5/05
4 100 5/21/07
5 340 6/23/06
2 250 4/3/06
My query such as
SELECT lot, value, date
FROM my table
How can I eliminate 1 row of lot 2 and chose the recent date only?
Thanks for your help
Daniel
View 3 Replies
View Related
May 12, 2004
Tables :
EmailUsers
ID int - PK
Email nvarchar(256)
ListsUsers
ListID int - FK to List Table - Combo PK
UserID int - FK to EmailUsers Table - Combo PK
When a person adds a user I need to:
A. insert them as a new entry into EmailUsers - no problem
B. insert their EmailUsers.ID from step A and ListID (passed in parameter) into ListsUsers - not so easy
C. if they're already in EmailUsers don't insert them but pass their existing EmailUsers.ID to part B
Any thoughts or examples I can follow? Maybe it's easier to do two seperate queries and control the if exists logic in asp.net?
View 9 Replies
View Related
May 22, 2001
Experts,
i have trouble while insert/update a field which contains double-byte characters (Chinese Traditional).
NO PROBLEM if i m using Enterprise Manager to view/edit the data. They are retrieved properly in the following:
(1) Enterprise Manager
(2) Query Analyzer
(3) Visual Basic
(4) Command prompt isql
EACH of the Chinese words are become a qustion mark '?' if the UPDATE SQL or stored procedure executed in the following:
(2) Query Analyzer
(3) Visual Basic
WHILE (4) Command prompt isql does not have the problem for the same UPDATE SQL and stored procedure.
Do you have any idea?
View 1 Replies
View Related
Jan 16, 2003
What data type in SQL server can be used in place of a double data type?? I don't even know what a double data type is but got a request to create a column with a data type of double.
Thanks.
View 1 Replies
View Related
Jul 30, 1999
Hello all,
I am using SQL Server 6.5 SP5a.
I have to use bcp to import two text files everyday for database update. The problem is that some of the character fields that are being imported have double-quotes and/or commas in them. When these are imported into the SQL Server tables additional double quotes are being added into these strings.
Example:
INCOMING STRING = a"a
IMPORTED STRING = "a""a"
INCOMING STRING = b,b
IMPORTED STRING = "b,b"
I have searched through BOL and have not been able to find any information.
Does anyone know what is causing this and if so how to correct it?
Thanks,
Bryan Ziel
View 3 Replies
View Related
Aug 14, 2002
if l have a field conating data that has quoutes around it like field idno "2809085009084 ". How would l remove the quotes ????
View 1 Replies
View Related
Feb 11, 2005
Hi,
I have a table with lots of records init and i want to make a simple query where i can show only the records with more then 1 time the same value,
problem is that i want to make a collumn primary key and there are still double values in it. :confused:
Thanx in front
Cheers Wimmo
View 2 Replies
View Related
Aug 9, 2006
Over some time now, I've been developing a fairly hefty stored procedure, that does a lot of computations, and fairly few table lookups.
When I look at the performance on my server (a dual Xeon HT) I can see that it only uses 1 out of 4 possible "cpus" to work on the calculations, while the three others idle out, and was wondering if I can somehow force it to use max available CPU power?
View 2 Replies
View Related
May 7, 2008
Did you any out there used Double Take Software for SQL Server 2000 for Data Protection ( Setting up DR Site )
Thanks
Venu
View 2 Replies
View Related
Jun 3, 2008
Hello!
I am currently workin on clearin a litte in our data collation, Can anyone tell me how i will get this to work..
I have this selected so far [URL=http://img247.imageshack.us/my.php?image=sqlresultatct2.png][/URL]
But i only want those selected who have the highest value in the last 3 columns in relation with their counterpart.... Anyway of doin that??
this is what i have to get the result-set
SELECT contact.contact_id,
contact_p.p_name,
contact_adr.adr_zip_code,
contact_p.p_first_name,
contact_p.p_last_name,
form_land_i_os.cdp_1y81__,
form_land_i_os.cdp_totalha,
form_land_i_os.cdp_ha_krak
FROM contact,
contact dub_contact,
contact_p,
contact_p dub_contact_p,
contact_adr,
contact_adr dub_contact_adr,
form_land_i_os,
form_land_i_os dub_form_land_i_os,
po_userdw
WHERE (contact.deleted IS NULL AND
dub_contact.deleted IS NULL AND
dub_contact_adr.adr_zip_code IS NOT NULL AND
contact.contact_status = 3 AND
dub_contact.contact_status = 3 AND
contact.p_id = contact_p.p_id AND
dub_contact.p_id = dub_contact_p.p_id AND
contact.adr_id = contact_adr.adr_id AND
dub_contact.adr_id = dub_contact_adr.adr_id AND
form_land_i_os.id = po_userdw.id AND
dub_form_land_i_os.id = po_userdw.id AND po_userdw.relation_id = contact.contact_id AND
contact_adr.adr_zip_code = dub_contact_adr.adr_zip_code AND
contact_p.p_first_name = dub_contact_p.p_first_name AND
contact_p.p_last_name = dub_contact_p.p_last_name AND
contact.contact_id <> dub_contact.contact_id AND
contact.adr_id <> dub_contact.adr_id AND
contact_p.p_name <> 'X')
ORDER BY contact_p.p_name
Thank you in advance wise gentlemen
Dont cross the road, if you cant get out of the kitchen
View 6 Replies
View Related
Jan 24, 2014
I have to insert "" in data and in column name in the output .csv file.I tried using Quotename function
for ex : QUOTENAME(policy.policyid, '"')AS PolicyID
Result
Policyid
"12135"
"34334"
"56765"
But i need policyId(i.e columnname) uswell in ""
Result
"PolicyId"
"12135"
"34334"
"56765"
How to amend the query.
View 2 Replies
View Related
Mar 29, 2006
i get an error when executing ,
Select sum(ToDouble(Jan_Hours)) from employeepayments
where Employer_Number = '2346' and [Year] = '2005'
the Jan_Hours is an varchar type of column.
how to get sum(Jan_Hours) + sum(Feb_hours) +
i also need sum (sum(Jan_Hours) + sum(Feb_hours))
View 17 Replies
View Related