Performing A Query Using Two Tables

Jul 20, 2005

Hi,

Have a database that contains various tables.

I need to run a query on two tables.

Table A contains a column called Titles

Table B contains a column called Uni_Titles

In Table B's column it contains multiple titles as shown below
separated by semi-colons in each row.


Table B Uni-Title Column
__________________________
Row 1: Landlord and tenant; Leases; Rent reviews

Row 2: Acquisitions; Advisers; Appointment; Contract term


Table A - Titles Column
_________________________
Table A's column contains a only one of the words in Table B's column

i.e. Landlord and tenant

I would like to obtain a count of how many times the same word or
phrases appears in the column of Table B.

Thanks

Steve

View 2 Replies


ADVERTISEMENT

Performing A Range Lookup Using Two Tables

May 16, 2006

Hello.

I have a car table, whose rows contain cars and their respective weight:

Ex: (1, 1000), (2,1100), (3, 900) etx.

I also have a car class table with the classes cars can fall into, based on a lower bound and an upper bound in which the car's weight must fit.

Ex: (Class1, 0, 999), (Class2, 1000, 1499), (Class3, 1500, 1999), etc.

I need to match each car to it's respective class. I've already search the database for post on this subject, but unfortunatelly my goal is yet to be reached. Can someone help?

Thanks in advance,

Hugo Oliveira

View 6 Replies View Related

DB Design :: Summing From Two Tables Then Performing Operation With 2 Sums

Jun 17, 2015

I am using sql server and I have a table called accnt with the fields ven1 and amnt1 and a table called acc1167 with fields ven, job#, and amnt. for this example these tables look like this

       accnt                          acc1167
    ven1     amnt1              ven     job#   amnt
    1167     100                1167     1      200     
    1152     50                  1167     2      300
    1167     110                1167     3      100
    1167     300                1167     4      200
    1252     1050              1167     5      200
    1167     210                1167     6      150
    1167     1150 
    1167     130 
    2113     800 
    1167     550
    1167     1200

I need to sum amnt1 for all the records in accnt with the ven1 of 1167, we will call this sumA. Then sum amnt in acc1167 for all records, we will call this sumB. next I need to divide sumB by sumA to get a ratio. finally I need to multiply each amnt value from acc1167 by the ratio and get a number that will then replace the acc1167 amnt value.

for example, sumA = 3750, sumB = 1150. taking these values, sumB/sumA = 0.307. I then replace every value in acc1167 amnt with 0.307*itself, so the final table should look like this:

          acc1167
    ven   job#    amnt
    1167   1      61.4
    1167   2      92.1
    1167   3      30.7
    1167   4      61.4
    1167   5      61.4
    1167   6      46.05

i have tried to use the sum function and and some insert, but i am very new to SQL and have never used sum before and don't know how to call from multiple tables, or how to store a ratio. Ive tried this:

    UPDATE     acc1167
    sum1 = sum amnt1 where ven1 = '1167'
    from accnt
    sum2 = sum amnt
    from accnt
    SET        amnt = sum2/sum1*amnt
    FROM       acc1167

View 2 Replies View Related

Performing A Hierarchical Query...

Mar 26, 2008

Hi. I'm trying to find out which "cases" have a new items added to our database. I have provided a sample layout.

ID ParentID Name CreateDate
358 2 SMITH, JOHN 3/3/2008 11:15:23 am
359 358 Invoice 3/5/2008 4:13:52 pm
360 358 Shipping 3/5/2008 5:11:09 pm
361 358 Receiving 3/6/2008 4:22:01 am

The main ID for this is 358. The invoice, shipping, and receiving items are child items. I would like to run a query that can report which cases have newly added items. This is hierarchical I guess and I'm quite lost. I hope this makes sense. Thanks for any help!

View 3 Replies View Related

Performing Insert Query With Check

Feb 29, 2008

hii,,i am using asp.net 2005 and sql server 2005.i have a web page in which i can enter details and it gets stored in a table in a database..in the table thrs a column called as sme_id,,what i want is when one inserts a new sme_id from the page,,it should check in the table so tht no duplicate sme_id wil b generated..,,this code is workin fine,,i just want to implement the above condition...here is the insert code which i have used along with sql datasource:::__________________________
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConflictDetection="CompareAllValues"
ConnectionString="<%$ ConnectionStrings:sme_trackerConnectionString %>"
InsertCommand="INSERT INTO SME_Master(SME_Id, FirstName, LastName, Type_of_SME, Agency_id, Agency_Name, Email, Address, Phone, Mobile, Fax, TimeZone_Id, Experience, City, State, Status, Level_Of_Exam, Other_Comments, Certificate, Expertise)
 VALUES (@SME_Id, @FirstName, @LastName, @Type_of_SME, @Agency_id, @Agency_Name, @Email, @Address, @Phone, @Mobile, @Fax, @TimeZone_Id, @Experience, @City, @State, @Status, @Level_Of_Exam, @Other_Comments, @Certificate, @Expertise)"
OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT * FROM [SME_Master]">
_______hope u got my problem,,,,,reply asap....thnks in advance

View 11 Replies View Related

Query On Performing Recursive Joins

Apr 14, 2007

I have a single table named PROCESS which contain following three fields

ProcessID
ParentID,
info

* Every process have a unique ProcessID and ave single parent process which is identified by ParentID.

* If a process does not have a Parent then its ParentID value is -1.

*Only single level of Parent-child hierarchy is maintained.


Can anyone please tell me the Query that uses Recursive JOINS to retrieve the ProcessID s based in following Conditions.

1. if the Parent's 'info' field contains given value then retrieve all the process under it.
2. Retrive all the process whose 'info' contains given value and excluding the Processes resulted from 1st conditiion

Thanks in advance

Bharath Booshan L

View 2 Replies View Related

Performing A Whitespace-insensitive Query

Jul 20, 2005

Hi,I am trying to concoct a query that will join rows on the basis of awhitespace insensitive comparison. For instance if one row has the value'a<space>b' and another has the value 'a<space><space>b' I want them to beconsidered equal (but not the same as 'ab')I am happy to do some T-SQL if that helps. Also I have a full-text index onthe column in question, but note that I am comparing rows against eachother, not to a fixed string.This is for a one-off job, so if there is no obvious way to do it on thedatabase, I will just bcp out the data and knock up some perl or somethingto do it. All other things being equal I would rather do it on the databasethough.Many thanksAndy

View 11 Replies View Related

Problem Performing A Join On A Function In A SQL Query

Sep 6, 2006

Hello,

Can someone explain why this code contains the following error:


Msg 4104, Level 16, State 1, Line 2

The multi-part identifier "TheTable.StartValue" could not be bound.



CREATE FUNCTION MyFunction(@StartValue int)

RETURNS @MyTable TABLE

(

NextValue int NOT NULL

)

AS

BEGIN

INSERT INTO @MyTable(NextValue)

VALUES (@StartValue + 1)

INSERT INTO @MyTable(NextValue)

VALUES (@StartValue + 2)

RETURN

END

GO

CREATE TABLE TheTable

(

StartValue int NOT NULL

)

GO

INSERT INTO TheTable(StartValue)

VALUES (10)

INSERT INTO TheTable(StartValue)

VALUES (20)

GO

SELECT *

FROM TheTable CROSS JOIN

MyFunction(TheTable.StartValue)

View 6 Replies View Related

DB Engine :: Linked Server - Getting Error When Performing Cross Instance Query With Joins

Apr 26, 2015

I've successfully created a Linked Server that connects a local DB Engine with another DB Engine through an ip over an extranet. I am able to run simple Select statement queries on the Local DB Engine and get results from the linked server. However when attempting to perform more complex queries that join tables from the linked server with tables from the local DB server, I get the following error message after several minutes of execution:

OLE DB provider "SQLNCLI11" for linked server "<ip of Linked Server>" returned message "Protocol error in TDS stream".
OLE DB provider "SQLNCLI11" for linked server "<ip of Linked Server>" returned message "Communication link failure".

Msg -1, Level 16, State 1, Line 0

Session Provider: Physical connection is not usable [xFFFFFFFF].

OLE DB provider "SQLNCLI11" for linked server "<ip of Linked Server>" returned message "Communication link failure".

Msg -1, Level 16, State 1, Line 0

Session Provider: Physical connection is not usable [xFFFFFFFF].

OLE DB provider "SQLNCLI11" for linked server "<ip of Linked Server>" returned message "Communication link failure".

Msg 10054, Level 16, State 1, Line 0

TCP Provider: An existing connection was forcibly closed by the remote host.

How I can resolve it. I've read on Distributed Transactions but I understand that it only applies to manipulation statements?

Both are SQL servers. Linked Server is SQL2008R2 if not mistaken. Local DB Engine is SQL2014.

View 3 Replies View Related

Error When Performing DTS

Nov 30, 2000

Can anyone assist me in solving this problem:

DTSTransformCopy: ValidateSchema failed; see Extended Error Information.
TransformCopy 'DTSTransformation_10' validation error: Source column too narrow to contain a valid value of destination column's datatype for column pair 1 (source column 'Col010'(DBTYPE_STR), destination column 'CHECKDAT' (DBTYPE_DBTIMESTAMP)).

Any help would be greatly appreciated.

Thanks,

Rey

View 1 Replies View Related

Performing Math Problem

Nov 19, 2003

I need to perform some division on the results of two alias columns that perform counts in a query. What is the best way to do this?

View 7 Replies View Related

Performing A Cascade Delete

Sep 3, 2002

How to delete a record from a parent table, all relating records in the child tables should also delete.
How to do it by MSSQL 7.0

ANB

View 1 Replies View Related

Performing An Insert Using NOT EXIST

Mar 8, 2005

I have two tables that I have to compare:


Table:PR
WBS1 WBS2 WBS3
123-456 1000 01
123-456 1000 02
123-456 2000 02
567-890 2000 01
567-890 2000 02

Table:PR_Template
WBS2 WBS3
1000 00
1000 01
1000 02
2000 00
2000 01
2000 02

After Insert I should have:

wbs1 wbs2 wbs3
123-456 1000 00
123-456 1000 01
123-456 1000 02
123-456 2000 00
123-456 2000 01
123-456 2000 02
567-890 1000 00
567-890 1000 01
567-890 1000 02
567-890 2000 00
567-890 2000 01
567-890 2000 02




Basically, I need to insert the wbs2 and wbs3 where it does not exist in each wbs1.

What I have now will find the values that need to be inserted for a particular project but I don't know how to go through each project and perform the insert:

Select * from PR_template Where Not Exists
(Select Wbs1, Wbs2, Wbs3 from PR where PR.WBS2 = PR_Template.WBS2
And PR.WBS3 = PR_Template.Wbs3 and pr.wbs1 = '123-456')
Order by wbs2, wbs3 asc

Thank You

View 11 Replies View Related

Using SUM And Performing Subtraction On Columns

Sep 4, 2013

I need to do SUM on a column values and then subtract it from the SUM of values on a column from another table. I am using SQL server Management Studio, but getting the errors on the following Query

SELECT note_id, cap_int_amt)- SUM (ttl_cap_int_amt) as SUM1,
sum(orig_fee_amt)-sum(ttl_qualfyng_fee_amt) as SUM2
FROM [spstrd00_starrpt].[dbo].[rpt23t]
where [rpt20t].note_id =[rpt23t].note_id

ERROR Message
Msg 208, Level 16, State 1, Line 1
Invalid object name 'dbo.rpt23t'.
Msg 4104, Level 16, State 1, Line 7
The multi-part identifier "rpt20t.note_id" could not be bound.
Msg 207, Level 16, State 1, Line 8
Invalid column name 'ttl_qualfyng_fee_amt'.

View 4 Replies View Related

Performing A Conditional Join

Oct 10, 2007

Hello,

I want to write a query that joins data in a different table based on a column value. The table is for a "Playlist" and holds play list items. The items can be video, audio, images, etc. The playlist table looks like this:

Table_Playlist
-----------------
ID (int)
MediaType (char)
MediaId (int)

Table_Audio
-----------------
MediaId (int)

Table_Video
--------------
MediaId (int)


If the Table_Playlist.[MediaType] column value = "Audio" then I want to join to the Table_Audio table. If the value = "Video" then I need the video table.

Hope that makes sense. Thanks

View 1 Replies View Related

Performing String Operation

Mar 29, 2008

Hi,

I have got a column with the string "I too Love Sql Server". I am trying an output as shown below:

I want to divide this into 4 columns :

Column1 Column2 Column3 Column4
I too Love Sql Server I.t.L.S.S

The Column 4 contains the first letter of each word. If the string contains only 2 words, Eg: "Sql Server" then Column 2 will be empty and only Column 1,3 and 4 will be filled.

How do I do this?

View 2 Replies View Related

Performing FTP Using Xp_cmdshell In Ms Sql 2005

Feb 27, 2008



Hi,
I want to copy xls file from remote server to my server.
i want to use xp_cmdshell to perform this operation.
can anybody help me out how to pass parameter to xp_cmdshell.

thanks in advance,

Chetan S. Raut.

View 3 Replies View Related

Help Needed While Performing Lookup

Dec 21, 2007

I have to look up a mapping table and add 5 more columns from the mapping table if the look on the first column in the mapping table and corresponding column in source is successful.
But if there is no matching record in then mapping table I still need the record to pass through with NA values.
Please help?

View 3 Replies View Related

Performing A Very Peculiar Task

Jun 1, 2007

Hello All,

I am tackling with unique request. I have to download the ".zip" files from the https and uncompress them. Now, the fetch process works fine when I am downloading the files. Using .net and .IO namespaces from system library.

Similarly after downloading I have to uncompress the files as these files are treated by compressed file folders by windows xp. I know it can be achieved by using the IO.compression class form system namespace.
But the only trouble here is IO.compression supports ".gz" and "Gzipstream.Uncompress" and I wonder how I would be able to get the ".zip" and "Zipstream.uncompress" done.

Thanks a million in all your help and advice. Also I appreciate for your time.

Regards
Sandesh

View 1 Replies View Related

Software For Performing Mass Design Changes

Jun 28, 2001

Hi,

I was wondering if anyone knows of any way, including third party tools, to replicate a design change on a table across many different databases. I have written an ASP script that allows me to copy multiple tables to multiple databases in one go but I need something that will allow me to replicate the design of a table by comparing source and destination tables. So far I have scripted most of it but I have no idea on which system table to get the identity information and it seems there must be an easier way!

Any help would be appreciated,

Seoras

View 1 Replies View Related

Performing Backups Using Network Resource

Sep 16, 1998

I`m having difficulty performing a SQL dump using a network drive. I have successfully created a backup device on a network drive but when I go to perform a backup using it I get the following error message: "Can`t open dump device `RSS4DATARSA3_Dump.Dat`, device error or device off line. Please consult the SQL Server error log for more details. (Message 3201)" I can successfully perform a backup using a local drive but not this network drive. I have checked the permissions on the network drive and is seems ok. I use the following command to try to perform the backup: "DUMP DATABASE RSA3 TO DISK = `Rss4DataRSA3_Dump.Dat WITH STATS = 10, INIT". Any help would be most appreciated. Thanks in advance!

View 2 Replies View Related

Performing Select Stmts. Using 2 Servers

May 25, 2002

It just seems like I should be able to use a 4 part naming convention to compare database tables that exist on 2 servers. It isn't always possible to link dbs because of security. Is there any other way to query between servers?

Thanks!

View 3 Replies View Related

Performing Statistics In SELECT Statement

May 30, 2008

I have listed below a sql statement generated by a MS Access query. The Access is the frontend, using a SQL Server 2005 View as the backend. I have already corrected the obvious differences between Access and SQL Server syntax, such as replacing UCase$ with UPPER,
replacing '_' with '.' between the db owner and view name, replacing IIF with IF, and replacing "D" with 'D' and "E" with 'E', but it still generates syntax errors (of course, with no explanation). As you can see, it is SUMing a field based on whether the value is 'D' or 'E', then using those calculated values to calculate a percentage. Can anyone out there let me know what I'm doing wrong?

SELECT dbo_vwDisplayUserList.DEPT_DESC, Sum(IIf(UCase$([Essential_Code])="D",1,0)) AS Department_Essential, Sum(IIf(UCase$([Essential_Code])="E",1,0)) AS EOC_Essential, Count(dbo_vwDisplayUserList.UserID) AS Total_Employees, Int([Department_Essential]/[Total_Employees]*100) AS [%Department_Essential], 100-Int([Department_Essential]/[Total_Employees]*100) AS [%EOC_Essential]
FROM dbo_vwDisplayUserList
GROUP BY dbo_vwDisplayUserList.DEPT_DESC
ORDER BY dbo_vwDisplayUserList.DEPT_DESC

View 1 Replies View Related

Get Identifier Back After Performing INSERT

Feb 8, 2006

Basically I have a table with 2 fields UserId (string) and UserName (uniqueidentifer). The default value for UserId is newid().

I can perform an insertion with
INSERT INTO MyTable(UserName) VALUES ('Foo Bar');

But I would like to retrieve the UserId that has just been created. How do I achieve that?

Thanks in advance,
Joannes

View 3 Replies View Related

Problem Performing Remote Queries

Aug 16, 2007

I am trying to a simple insert statement from a remote applicationagainst a sql server 2005 database. To fix the problem I was having,I had to grant the Login I was using the role of sysadmin. However Idon't want this user to have that kind of control, what would be thebest role to allow the user full access(including remoting) to onlyone particular database?

View 5 Replies View Related

Permision Denied Performing FTP Task

Sep 12, 2007



Hi,

I am having an issue when performing an FTP atsk to a remote site ( as opposed to internaly on a LAN )

I get the error "[Connection manager "FTP Connection Manager"] Error: An error occurred in the requested FTP operation. Detailed error description: 200 Type set to IMAGE. 200 command successful 550 permission denied . "

I can manually FTP to this site from my machine, using either a CMD window or Windows explorer. I can create folders, deposit files, delete files etc so I seem to have full control. This task works when testing on our local FTP server on the LAN. The "Test" connection works when configuring the connection to the remote site. It is just at runtime that the task fails.

Can anybody come up with any ideas why this may be ?

Thanks.

View 3 Replies View Related

Message When Performing End User Sort

Aug 29, 2007

Hi,
I have added interactive sort to report. When i perform the sort in the preview of the report, i see a message 'Report is being generated'. But when i do the sorting from Report viewer control, the screen goes blank before the sorted data comes up.
Is there any way I can display a message telling sorting is in progress?
Any help in this regard is appreciated.

Thanks.

View 3 Replies View Related

Lookup Task Not Performing Correctly!

Apr 8, 2008

Hi, I'm using the lookup task to perform updates on some records and it seems to be working correctly but isn't making all updates. I have a case where there are 543 rows in my source connection, there are 436 of them that do not match the date column of the 543 in my destination table. It only updated 224 of them when it should have updated all 436? Does anyone know why it would only update this many instead of all? I also had another that only updated 18 out of 19 instead of all 19.

thanks,

View 4 Replies View Related

Browser Role Not Performing As Expected

Nov 1, 2007

Hi guys,

I have created a user on the domain computer and this user has given a limited privilege. I need this user only to browse reports on the Report Manager so I gave him a browser role. However, when this user login to the report manager using his account, he is able to not only the Contents tab of the report manager but also the Properties tab where he can do admin stuff. I'm not sure where exactly I have to troubleshout this issue, either on the domain computer or Report Manager. I'm not sure if there is any set up done on the domain computer that enable a User account to act like an Admin when they login on the Report Manager.

Please this is urgent...heeeeeeeeeeeeeeeeelp!

thx!

View 9 Replies View Related

Permissions Are Insufficient For Performing ListChildren()

Jan 16, 2008

I'm developing an asp.net app that will list the reports available on the report server. The app works OK on my local machine but when I deploy it I run into a permissions problem:

Exception Details: System.Web.Services.Protocols.SoapException: System.Web.Services.Protocols.SoapException: The permissions granted to user 'NT AUTHORITYNETWORK SERVICE' are insufficient for performing this operation. ---> Microsoft.ReportingServices.Diagnostics.Utilities.AccessDeniedException: The permissions granted to user 'NT AUTHORITYNETWORK SERVICE' are insufficient for performing this operation. at Microsoft.ReportingServices.Library.ListChildrenAction.PerformActionNow() at Microsoft.ReportingServices.Library.RSSoapAction`1.Execute() at Microsoft.ReportingServices.WebServer.ReportingService2005Impl.ListChildren(String Item, Boolean Recursive, CatalogItem[]& CatalogItems) --- End of inner exception stack trace --- at Microsoft.ReportingServices.WebServer.ReportingService2005Impl.ListChildren(String Item, Boolean Recursive, CatalogItem[]& CatalogItems) at Microsoft.ReportingServices.WebServer.ReportingService2005.ListChildren(String Item, Boolean Recursive, CatalogItem[]& CatalogItems)

My code uses the DefaultCredentials:
ReportingService2005 rService = new ReportingService2005();rService.Credentials = System.Net.CredentialCache.DefaultCredentials;
CatalogItem[] catalogItems;
catalogItems = rService.ListChildren("/", true);
I can avoid the exception if I use the Administrator account:

System.Net.CredentialCache cache = new System.Net.CredentialCache();// Add a NetworkCredential instance to CredentialCache.// Negotiate for NTLM or Kerberos authentication.cache.Add(new Uri(ReportServer), "Negotiate", new System.Net.NetworkCredential("Administrator", "<password>", "<domain>")); //Assign CredentialCache to the Web service Client Proxy(myProxy) Credentials property.rService.Credentials = cache;

I'm pretty sure using the Administrator account here is not the best practice. Any suggestions?

Thanks,
Al

View 3 Replies View Related

Performing Mathematical Transcations With A Sql Server Database

Feb 20, 2008

Hi,I would like to know if its possible to add/subtract/multiply/divide values between a cell in a database and a textbox/label on a web form? how would I go about doing this? Also, I would like a number from a cell to appear in a label when a page first loads. How can I achieve this? 

View 8 Replies View Related

Job Running With Status Performing Completion Action

Mar 28, 2002

Hello , I noticed thsi morning I have 4 jobs having job status
"performing completion action"
normaly it takes 20 min 1 hr to finish longest job.

What does it mean?

View 2 Replies View Related

Performing Multiple Inserts In Mssql Sproc

Apr 27, 2005

I am trying to insert a message into my database for every "league" I have in the database. I would like to do this in one sproc but am not sure how this would be done. Here is the loop if it has to be done outside of sql

Code:


message = "This is a test message."
leagues[] = getAllLeaguesInSite()

begin transaction
for each league in leagues
insertLeagueMessage(league, message)

if noErrors
commit transaction
else
rollback transaction


-----
as you can see it would be nice to be able to do this all in mssql . If it can be done please let me know.

Thanks

View 4 Replies View Related







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