Showing posts with label tables. Show all posts
Showing posts with label tables. Show all posts

Friday, March 30, 2012

Link two tables using partial word match

Hi All,

I need to link two tables using partial word match.

How can I write a SQL statement to do so? (I am using MS-Access.)

Table One: [Table Name: tblStreet] [Field Name: Street]
123 ABC Street
124 ABC Street
125 ABC Street
1 XYZ AVE
2 XYZ AVE
3 XYZ AVE
10 CBS Street
11 CBS Street
12 CBS Street
100 Apple Road
101 Apple Road
102 Apple Road

Table Two: [Table Name: tblWord] [Field Name: Word]
ABC
CBS

The output should be:

123 ABC Street
124 ABC Street
125 ABC Street
10 CBS Street
11 CBS Street
12 CBS Street

Could this be done?

Thank you in advanced.

- Grasshopper -SQL Learner wrote:

Quote:

Originally Posted by

Hi All,
>
I need to link two tables using partial word match.
>
How can I write a SQL statement to do so? (I am using MS-Access.)
>
Table One: [Table Name: tblStreet] [Field Name: Street]
123 ABC Street
124 ABC Street
125 ABC Street
1 XYZ AVE
2 XYZ AVE
3 XYZ AVE
10 CBS Street
11 CBS Street
12 CBS Street
100 Apple Road
101 Apple Road
102 Apple Road
>
Table Two: [Table Name: tblWord] [Field Name: Word]
ABC
CBS
>
The output should be:
>
123 ABC Street
124 ABC Street
125 ABC Street
10 CBS Street
11 CBS Street
12 CBS Street
>
Could this be done?
>
Thank you in advanced.
>
- Grasshopper -


SELECT t.* FROM tblStreet t WHERE EXISTS(SELECT 1 FROM tblWord w WHERE
t.Street LIKE '%'+Word+'%')

--------
Alex Kuznetsov
http://sqlserver-tips.blogspot.com/
http://sqlserver-puzzles.blogspot.com/|||Thank you so much Alex! It works. The only thing is that I replaced
the "%" with "*" since this is Transact SQL in Access. : )

By the way, is there any good book that I can use to learn SQL of this
kind?

- Grasshopper -

Link two tables in UPDATE - ERR:single-row subquery returns more than one row

1 UPDATE PM_ASSIGNMENTS
2 SET PM_ASSIGNMENTS.JOB_TYPE_CODE = (SELECT PM_TASK_DETAILS.JOB_TYPE_CODE
3 FROM PM_ASSIGNMENTS, PM_TASK_DETAILS
4 WHERE ((PM_ASSIGNMENTS.TASK_NUMBER) = (PM_TASK_DETAILS.TASK_NUMBER))
5* AND (PM_ASSIGNMENTS.TASK_NUMBER = '1000'))
SQL> /
SET PM_ASSIGNMENTS.JOB_TYPE_CODE = (SELECT PM_TASK_DETAILS.JOB_TYPE_CODE
*
ERROR at line 2:
ORA-01427: single-row subquery returns more than one rowthe sub-query is returning more than one row for the given condition.

either group-by them, or give all user-key conditions.

regards,
Raghu.sql

Link Two tables

Hi All,
I want link two tables from two different database located on different server. they both are not have unique reference.
Table1 from db1 is one field(Emp_id) is auto increment number And another one is table2 from db2(Newly created table). I need some fields from table1.db1 to table2 db2. When all are user modified table1.db1 then automatically update table2.db2

thanksI think you recieved answer to your question.

http://www.msdner.com/forum/thread586326.html

Not sure what else you are looking for.

Link to DB2

Hi all,

I'd like to know what the best means available is to enable distributed
queries from a SQL Server 2000, on tables in BOTH SQL Server 2000 and a
remote DB2 server (the latter is not yet available for testing).

So, I would be wanting to write queries or SP's like:

select t1.field1, t1.field5, t1.field6, t2.field55, t2.field22
from MySQLServer.mydb.dbowner.tableXXX as t1
inner join ThatDB2Server.thatdb.thatowner.tableYYY as t2 on t2.field11
= t1.field99
where t1.field44 = @.foobar

I'm aware of at least two ways to go here:

1) in SQL Server 2000, create a linked server to the remote DB2
server, either using the wizard or sp_addlinkedserver, and using either
an OLEDB or ODBC connection;

2) using MS Host Integration Server (HIS).

Since I've only just today learnt about HIS, I don't know very much
about it.

Questions:
(a) are options (1) and (2) mutually exclusive, or does one depend on
the other?
(b) can I do (1) without having to bother with (2)? If this, where
would I get hold of the required OLEDB/ODBC Provider?
(c) Is there another way(s) to go about this task?

HYCH,
Robrobertino wrote:

> 1) in SQL Server 2000, create a linked server to the remote DB2
> server, either using the wizard or sp_addlinkedserver, and using either
> an OLEDB or ODBC connection;
> 2) using MS Host Integration Server (HIS).
> Since I've only just today learnt about HIS, I don't know very much
> about it.
> Questions:
> (a) are options (1) and (2) mutually exclusive, or does one depend on
> the other?
> (b) can I do (1) without having to bother with (2)? If this, where
> would I get hold of the required OLEDB/ODBC Provider?
It depends :) If you would like to use Microsoft OLEDB Provider for DB2
you have to use HIS but there are third party OLEDB drivers like
http://www.hitsw.com/products_servi...db2_dsheet.html
or IBM OLEDB provider. I worked with IBM and HIS provider for linked
servers and everything went OK but i was using only openquery to access
data not joins with tables from DB2.

Lukasz

Wednesday, March 28, 2012

Link to another SQL database table

Hello All,
I have a question on linking tables with SQL Server. I have SQL Server 2000 with database A on machine A. I have SQL Server 2000 with database B on machine B. I want to link tables from the database on machine A into a database on machine B. I am not quite sure how to do this - I believe this can be done as I have seen it before. Any information and or resources to direct me to would be greatly appreciated.

ThanksYou can add a linked server using Enterprise Mangler (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/howtosql/ht_servpem_1ozd.asp), or using sp_addlinkedserver (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_sp_adda_8gqa.asp) from within Query Analyzer.

-PatP|||http://www.databasejournal.com/features/mssql/article.php/3085211 for detailed explanation.



HTH|||Thanks for the information, I appreciate the responses.

I just have a follow on question. It seems that you can link an entire SQL server but is there any way around this if you cannot have full access to all the databases and tables within?

For example, the SQL Server I need to link to has several databases. I need to link to 4 tables in one database. I will not have the authority to link in the entire database. With Access I can link to a database and select the tables I need to link in, with the SQL Server method I don't see that I can do this (it just may be that I am not doing this right - not too familiar with SQL Server).

Any ideas?
Thanks|||For the linked server privilege to access entire database is not required, you can control the privileges for any logon pertaining to a table in the database.

If the underlying user has required privilege to access the table, then LS connection will be successful and only data can be retrieved from permitted tables.

Refer to the books online for more information on Linked servers and its security.
H
TH|||A linked server gives one server (machine) access to another machine. The user is what determines the permissions, so even though you only expect to be able to "see" or use four tables, depending on the login/user being used you may have access to some other number of tables. You might have a user on your local system that has no permissions at all on the remote system. You might have another local user that would have administrator rights on the remote system, therefore they could access every table.

This probably seems a bit complex after dealing with the much simpler security model that MS-Access (actually Jet, the underlying database engine) provides, but it is actually much more powerful.

-PatP|||Thanks for the information - and thanks to all the responses I am now getting further. In a testing environment I have created the user, limited access to the tables and currently I have used the linked server feature to link in the database.

The main point of doing this was so that I could create a view in my main database to combine data from the linked in database tables. This where I am running into a problem. I keep receiving a message "Could not find "servername" in sysservers, please run sp_addlinkedservers". I have followed the article provided in this thread but was not successful, I cannot get any of the items to execute, I receive syntax errors.

I am not sure if I am in over my head here. Any help would be appreciated.|||Usually at least, linked server information isn't security sensitive. If it is ok, can you post what you tried to execute and what error messages you received? Without at least some hints, I can't help much!

-PatP

link tables to sql server by code

using access 2000
how i can link a table from sql server by code?
Your best bet is to write this code in Access/VBA. The code creates a
DAO TableDef object and sets its various properties (connection
string, etc.) and appends it to the TableDefs collection. Here's a
sample where tdf represents a TableDef object:
Set tdf = db.CreateTableDef(strLinkName)
' Set the Connect and SourceTableName
' properties to establish the link
tdf.Connect = strConnectionString
tdf.SourceTableName = strSourceTableName
' Append to the database's TableDefs collection
db.TableDefs.Append tdf
--Mary
On Wed, 29 Dec 2004 16:44:35 +0200, "Sam" <focus10@.zahav.net.il>
wrote:

>using access 2000
>how i can link a table from sql server by code?
>

link tables to sql server by code

using access 2000
how i can link a table from sql server by code?Your best bet is to write this code in Access/VBA. The code creates a
DAO TableDef object and sets its various properties (connection
string, etc.) and appends it to the TableDefs collection. Here's a
sample where tdf represents a TableDef object:
Set tdf = db.CreateTableDef(strLinkName)
' Set the Connect and SourceTableName
' properties to establish the link
tdf.Connect = strConnectionString
tdf.SourceTableName = strSourceTableName
' Append to the database's TableDefs collection
db.TableDefs.Append tdf
--Mary
On Wed, 29 Dec 2004 16:44:35 +0200, "Sam" <focus10@.zahav.net.il>
wrote:

>using access 2000
>how i can link a table from sql server by code?
>

Link Tables in SQL Server

Can I create Link Table in SQL Sever that links to a MS Access Table?You create a "Linked Server" to the Access database.

See Books OnLine under Linked Servers.|||You can use the OLEDB provider for Jet for MS Access database.

Link Tables in SQL Server

Can I create Link Table in SQL Sever that links to a MS Access Table?You create a "Linked Server" to the Access database.

See Books OnLine under Linked Servers.|||You can use the OLEDB provider for Jet for MS Access database.

Link tables in SQL databse

How to create links to other tables within SQL database?Can you define more clearly, Alan?
"Alan" <Alan@.discussions.microsoft.com> wrote in message
news:4BDE1092-1974-4958-990B-2FF2B8485DE2@.microsoft.com...
> How to create links to other tables within SQL database?|||If you want to query a table in another database, but on the same server, as
long as your login is a mapped user in the other database, all you need to do
is qualify the table in your FROM clause:
SELECT ...
FROM <database_name>.<owner>.<table_name|view_name>
WHERE ...
Now, if you want to query a database hosted by another server, you have
several optons:
OPENDATASOURCE
OPENRESULTSET
OPENQUERY
LINKED SERVER
Remember that these are not limited to just remote SQL Servers but any OLEDB
or ODBC compliant source where the drivers have been properly loaded on the
server in question.
Sincerely,
Anthony Thomas
"Alan" wrote:
> How to create links to other tables within SQL database?sql

Link tables in SQL databse

How to create links to other tables within SQL database?
Can you define more clearly, Alan?
"Alan" <Alan@.discussions.microsoft.com> wrote in message
news:4BDE1092-1974-4958-990B-2FF2B8485DE2@.microsoft.com...
> How to create links to other tables within SQL database?
|||If you want to query a table in another database, but on the same server, as
long as your login is a mapped user in the other database, all you need to do
is qualify the table in your FROM clause:
SELECT ...
FROM <database_name>.<owner>.<table_name|view_name>
WHERE ...
Now, if you want to query a database hosted by another server, you have
several optons:
OPENDATASOURCE
OPENRESULTSET
OPENQUERY
LINKED SERVER
Remember that these are not limited to just remote SQL Servers but any OLEDB
or ODBC compliant source where the drivers have been properly loaded on the
server in question.
Sincerely,
Anthony Thomas
"Alan" wrote:

> How to create links to other tables within SQL database?

Link tables in SQL databse

How to create links to other tables within SQL database?Can you define more clearly, Alan?
"Alan" <Alan@.discussions.microsoft.com> wrote in message
news:4BDE1092-1974-4958-990B-2FF2B8485DE2@.microsoft.com...
> How to create links to other tables within SQL database?|||If you want to query a table in another database, but on the same server, as
long as your login is a mapped user in the other database, all you need to d
o
is qualify the table in your FROM clause:
SELECT ...
FROM <database_name>.<owner>.<table_name|view_name>
WHERE ...
Now, if you want to query a database hosted by another server, you have
several optons:
OPENDATASOURCE
OPENRESULTSET
OPENQUERY
LINKED SERVER
Remember that these are not limited to just remote SQL Servers but any OLEDB
or ODBC compliant source where the drivers have been properly loaded on the
server in question.
Sincerely,
Anthony Thomas
"Alan" wrote:

> How to create links to other tables within SQL database?

Link tables from other database into SQL

I was wondering if anyone knew of a way to dynamically link a table from a
COBOL (I think) database into a SQL database. I have an ODBC driver that I
have been using to link the tables into Access, but would like to do the same
in SQL Server 2000.
Thanks in advance for any replies!
Cobol is a language so I'm not real sure what database you
are trying to connect to. But if you have a driver for the
database, install it on the SQL Server box. For the linked
server, you'll need to follow similar steps for the
configuration that you used in Access when linking the
tables. Look up linked servers in SQL Server books online to
find more information on creating linked servers in SQL
Server. You link to the server/database in SQL Server rather
than individual database objects as you do in Access.
-Sue
On Fri, 4 Mar 2005 07:49:09 -0800, "cjohnson300"
<cjohnson300@.discussions.microsoft.com> wrote:

>I was wondering if anyone knew of a way to dynamically link a table from a
>COBOL (I think) database into a SQL database. I have an ODBC driver that I
>have been using to link the tables into Access, but would like to do the same
>in SQL Server 2000.
>Thanks in advance for any replies!

Link tables from other database into SQL

I was wondering if anyone knew of a way to dynamically link a table from a
COBOL (I think) database into a SQL database. I have an ODBC driver that I
have been using to link the tables into Access, but would like to do the sam
e
in SQL Server 2000.
Thanks in advance for any replies!Cobol is a language so I'm not real sure what database you
are trying to connect to. But if you have a driver for the
database, install it on the SQL Server box. For the linked
server, you'll need to follow similar steps for the
configuration that you used in Access when linking the
tables. Look up linked servers in SQL Server books online to
find more information on creating linked servers in SQL
Server. You link to the server/database in SQL Server rather
than individual database objects as you do in Access.
-Sue
On Fri, 4 Mar 2005 07:49:09 -0800, "cjohnson300"
<cjohnson300@.discussions.microsoft.com> wrote:

>I was wondering if anyone knew of a way to dynamically link a table from a
>COBOL (I think) database into a SQL database. I have an ODBC driver that I
>have been using to link the tables into Access, but would like to do the sa
me
>in SQL Server 2000.
>Thanks in advance for any replies!

Link Tables

Hi,
Trying to link tables from Access 2000 to SQL 2000. Am successfully linking
tables as long as there are no spaces in the table name.
tableA from access to TableA to SQL link successfully.
table B from access to TableB or table B get odbc -- call failed
help
stoneystoney wrote:
> Hi,
> Trying to link tables from Access 2000 to SQL 2000. Am successfully linking
> tables as long as there are no spaces in the table name.
> tableA from access to TableA to SQL link successfully.
> table B from access to TableB or table B get odbc -- call failed
> help
> stoney
Hi Stoney
You don't say how you link the tables, but try to put [] around the name
- e.g. [Table B].
--
Regards
Steen Schlüter Persson
Database Administrator / System Administratorsql

Link Tables

I have two databases and one of them contains a table that
I would like to link between the two. I have used the link
table wizard to link a table from a secondary database
with Microsoft Access and was wondering if there is a way
to do this in SQL Server 2KThank you so very much!!!|||Try a View
CREATE VIEW DatabasenameN.Owner.VW_test
AS
SELECT a.V1, a.V2, b.V3 ......
FROM Databasename1.Owner.Table1 a
JOIN Databasename2.Owner.Table2 b on a.Vx = b.Vy
WHERE ......
Hope this Helps

Link tables

Is there a way to incorporate link tables in SQL Server similar, if not
the same way Access ineracts with them?Can you explain what a "link table" is?
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"EESP" <johnson4@.wwu.edu> wrote in message
news:1145653487.044408.232680@.g10g2000cwb.googlegroups.com...
> Is there a way to incorporate link tables in SQL Server similar, if not
> the same way Access ineracts with them?
>|||EESP wrote:
> Is there a way to incorporate link tables in SQL Server similar, if not
> the same way Access ineracts with them?
If the table is located on the same SQL Server instance that you are
using then no kind of linking is required. You can access those tables
by using a three-part name in the form:
database_name.schema_name.object_name.
If the table is located on a different server or on another instance or
not in SQL Server at all then you can create a "linked server" (a
virtual server that corresponds to an OLEDB data source). Lookup linked
servers in Books Online.
--
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--

Link Tables

Hi,
Still i m not getting the result. My question is can link the table in SQL like MSAccess has.(from other database we can use the table). Bcz i want a data from other database table and use the table data for other database.

Thanks
imtdid u mean to join the table or database....

Quote:

Originally Posted by imtmub

Hi,
Still i m not getting the result. My question is can link the table in SQL like MSAccess has.(from other database we can use the table). Bcz i want a data from other database table and use the table data for other database.

Thanks
imt

|||

Quote:

Originally Posted by reon

did u mean to join the table or database....


I want if the data change one table it need to sutomatically update second table. The both table are not in one database. They are diffrent database in sql server. In Access i can use link table to get data from another database table. In sql i don;t know how to use. If anybody knows how to do this option it will very helpfull.

Thanks

LInk Tables

Hi,
I have created a link server within my enterprise. I can see the
server - which is on a c-isam db - and all the the tables.
What I am unable to do is query any of the tables.
Link Server = Rubicon
Table Name = qc_raw_mat_cat.
select * from rubicon..qc_raw_mat_cat
What have I missed / messed up?
Many thanks
example
select * from rubicon..qc_raw_mat_catTo reference a table in a linked server, you need to use
LinkedServer.CatalogOrDatabase.SchemaOrOwner.Object
Try:
select *
from rubicon...qc_raw_mat_cat
-Sue
On Thu, 7 Apr 2005 00:23:02 -0700, "MMouse99"
<MMouse99@.discussions.microsoft.com> wrote:

>Hi,
>I have created a link server within my enterprise. I can see the
>server - which is on a c-isam db - and all the the tables.
>What I am unable to do is query any of the tables.
>Link Server = Rubicon
>Table Name = qc_raw_mat_cat.
>select * from rubicon..qc_raw_mat_cat
>What have I missed / messed up?
>Many thanks
>
>example
>select * from rubicon..qc_raw_mat_cat

LInk Tables

Hi,
I have created a link server within my enterprise. I can see the
server - which is on a c-isam db - and all the the tables.
What I am unable to do is query any of the tables.
Link Server = Rubicon
Table Name = qc_raw_mat_cat.
select * from rubicon..qc_raw_mat_cat
What have I missed / messed up?
Many thanks
example
select * from rubicon..qc_raw_mat_cat
To reference a table in a linked server, you need to use
LinkedServer.CatalogOrDatabase.SchemaOrOwner.Objec t
Try:
select *
from rubicon...qc_raw_mat_cat
-Sue
On Thu, 7 Apr 2005 00:23:02 -0700, "MMouse99"
<MMouse99@.discussions.microsoft.com> wrote:

>Hi,
>I have created a link server within my enterprise. I can see the
>server - which is on a c-isam db - and all the the tables.
>What I am unable to do is query any of the tables.
>Link Server = Rubicon
>Table Name = qc_raw_mat_cat.
>select * from rubicon..qc_raw_mat_cat
>What have I missed / messed up?
>Many thanks
>
>example
>select * from rubicon..qc_raw_mat_cat
sql