Programati​cally Link Tables wiith SQL
Is there a way to programatically link tables from one Access Database
to another using SQL?
Thanks!
Tim Erickson
I can't give you a definite answer, but a direction to start looking would be to check the MS website and see if you can find an example of how to do it either using ActiveX or a combination of ActiveX and a macro. If you can find such an example, all you have to do is recast the calls to LV-style ActiveX operations. Alternately you may find that such remote operation is not possible--in which case you have your answer.
In any case, please keep the list posted with what you find as I sometimes get stuck using Access and the information could be helpful.
Mike...
Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion
"... after all, He's not a tame lion..."
Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps
Similar Messages
-
I am running SQL server 2008 and want to link to a table in Access 2007. I have read many articles but most say to import from Access into SQL. Importing the table will not serve my needs as the data will not be dynamic. Is it possible to link to an Access
table from SQL?
BruceYou can create a linked server in SQL Server to connect to Access and query the table in Access
http://msdn.microsoft.com/en-us/library/ff772782(v=sql.105).aspx
YOu need to use the OLE DB provider for Jet inorder for Access.
http://msdn.microsoft.com/en-us/library/ms175866(v=sql.105).aspx
Regards, Ashwin Menon My Blog - http:\\sqllearnings.com -
How to create a DSN-less connection to SQL Server for linked tables in Access
hey
i cant understand how i use that Function
if that information what you need
stLocalTableName: dbo_user_name
stRemoteTableName: user_name
stServer :sedo2015.mssql.somee.com
stDatabase :sedo2015
stUsername :sedo_menf_SQLLogin_1
stPassword :123456789
how will be that Function??
please write that Function to me
'//Name : AttachDSNLessTable
'//Purpose : Create a linked table to SQL Server without using a DSN
'//Parameters
'// stLocalTableName: Name of the table that you are creating in the current database
'// stRemoteTableName: Name of the table that you are linking to on the SQL Server database
'// stServer: Name of the SQL Server that you are linking to
'// stDatabase: Name of the SQL Server database that you are linking to
'// stUsername: Name of the SQL Server user who can connect to SQL Server, leave blank to use a Trusted Connection
'// stPassword: SQL Server user password
Function AttachDSNLessTable(stLocalTableName As String, stRemoteTableName As String, stServer As String, stDatabase As String, Optional stUsername As String, Optional stPassword As String)
On Error GoTo AttachDSNLessTable_Err
Dim td As TableDef
Dim stConnect As String
For Each td In CurrentDb.TableDefs
If td.Name = stLocalTableName Then
CurrentDb.TableDefs.Delete stLocalTableName
End If
Next
If Len(stUsername) = 0 Then
'//Use trusted authentication if stUsername is not supplied.
stConnect = "ODBC;DRIVER=SQL Server;SERVER=" & stServer & ";DATABASE=" & stDatabase & ";Trusted_Connection=Yes"
Else
'//WARNING: This will save the username and the password with the linked table information.
stConnect = "ODBC;DRIVER=SQL Server;SERVER=" & stServer & ";DATABASE=" & stDatabase & ";UID=" & stUsername & ";PWD=" & stPassword
End If
Set td = CurrentDb.CreateTableDef(stLocalTableName, dbAttachSavePWD, stRemoteTableName, stConnect)
CurrentDb.TableDefs.Append td
AttachDSNLessTable = True
Exit Function
AttachDSNLessTable_Err:
AttachDSNLessTable = False
MsgBox "AttachDSNLessTable encountered an unexpected error: " & Err.Description
End Functionthanks more thanks for you
look i add that code in form
it worked but i cant add recored why ??
Private Sub Form_Open(Cancel As Integer)
Call AttachDSNLessTable("dbo_user_name", "user_name", "sedo2015.mssql.somee.com", "sedo2015", "sedo_menf_SQLLogin_1", "123456789")
End Sub -
Many to Many PL/SQL - how to nest a linking table?
I have two objects that are linked with a many-to-many relations. These two objects have to be nested inside a third object. How should I do ?
I created the type and the table for A, I did the same for B and I finally created the linking table for A and B. How shall I nest this table inside the object C?
Thank you very much for your help as I am new to PL SQL.I need to create one object called Container. From a modelling perspective, this object has contains all the other objects.
The other objects are items and composed items. The Container contains the items (it is a one-to-many relationships so I created a nested table) but it also contains composed items, which are items linked to parts and this is a many-to-many relationship. How do I do to include the many-to-many in the object container? I included question marks when I did not know. Thank you
CREATE OR REPLACE TYPE Item_type (
Id NUMBER (6),
Type CHAR (7)) ;
CREATE OR REPLACE TYPE Part_type (
Id NUMBER (6),
Type CHAR (7)) ;
CREATE TABLE Item OF Item_type
(Id NOT NULL,
PRIMARY KEY (Id));
CREATE TABLE Part OF Part_type
(Id NOT NULL,
PRIMARY KEY (Id));
CREATE TABLE ComposedItems
(ItemId REF Item_type ,
PartId REF Part_type);
CREATE OR REPLACE TYPE ComposedItems_nested as TABLE OF *????????*
CREATE OR REPLACE TYPE Item_type (
Id NUMBER (6),
Type CHAR (7));
CREATE OR REPLACE TYPE Item_nested as TABLE OF Item_type;
CREATE OR REPLACE TYPE Container_type (
Id NUMBER (6),
Type CHAR (7),
Item Item_nested,
/ -
How to create linked server in sql 2005 to access free table visual foxpro 9 step by step
Hi All, I want to connect to dbf file visual foxpro by using linked server in sql 2005, but i can't do, i hope getting best anwser from every body in forum.
Thanks all.Hi doanpq,
Please download and install OLE DB Provider for Visual FoxPro 9.0, which exposes OLE DB interfaces that you can use to access Visual FoxPro databases and tables from other programming languages and applications. Please see:
http://www.microsoft.com/en-us/download/details.aspx?id=14839
Then, please follow up the following article to create a linked server:
Creating Linked Servers:
http://technet.microsoft.com/en-us/library/ff772782(v=sql.105).aspx
For more information, you can also take a look at the following article, especially Dave K's comment:
http://blog.dbase.integralwebsolutions.co.za/2008/10/accessing-your-dbf-tables-via-linked.html
Elvis Long
TechNet Community Support -
Adding a table to a linked server in SQL
Hi
I have a linked server in SQL server management studio.
It has a list of oracle tables that can be reached through it. To add tables to the list do i need set up some permissions on the Oracle side?
thanks a lot for any helpTo add to what Sunny posted. If the linked server uses a fixed user/password to connect to Oracle then in the Oracle database all you need do is get the required object privileges granted to the Oracle username being used in the linked server to Oracle. The grant can be direct to the username or to a role the username has been granted.
If the MS SQL Server Linked Server to Oracle does not use a fixed user then the SQL Server usernames have to also exist in Oracle or have been mapped via the linked server definition to an Oracle username. Different SQL Server users can have different Oracle usernames associated to them via the linked server definition so you may need the Oracle grants issued to one or more Oracle usernames.
Most linked servers use fixed users to connect to Oracle but you need to be aware this is not always true and when it is not true the list of tables shown under the linked server can vary based on the SQL Server user logged in.
HTH -- Mark D Powell -- -
Can Oracle view refer a table in Sql Server Database
Can a view created in Oracle database refer a table created in SQL Server database. If yes, how do we do it. Code will be very help full.
Again, if yes does it require any special software and what would be price of that software.
Thanks for your response in advance.
Venkat SathiamurthyYou would need to configure Oracle Heterogeneous Connectivity to create a database link to the SQL Server system. This can either be done via the Oracle Transparent Gateway for Microsoft SQL Server, which retails for $15,000 per server at http://store.oracle.com or by configuring Oracle Generic Connectivity and using ODBC to go after the SQL Server data. Depending on the operating system you run Oracle on, there may be a free (or cheap) ODBC driver for SQL Server that could be used.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
Group by languages in multilingual table in sql server
Hi ,
I am having a multilingual table in SQL server 2008 , the table has two columns ID and Text
The text column has English, Chinese and other language texts.
I need a resultset grouped by the languages and count of id like
Language count_of_id
English 25
Chinese 10
other languages 3
Is this possible? Can you please help me?Good day SqlServer_learn
I have a saying that I always uses: anything is possible in developing, if you have the appropriate resources (change the existing solution could be part of the way to solve...)
regarding your question, there is simple solution, but for most cases, I highly recommend to change the table structure and add a column for the culture of the text (like: en-us for english,
he-il for Hebrew and so on..).
Since you are using unicode column like nvarchar to store multi language text,
we can get the language from the text itself, as long as it include characters from that language (text which include only numbers for example we we consider as default language since it is the same in all languages).
step 1: First you need an accessory table (Named like UnicodeMapping) which include all unicode characters and the number of the char in unicode (a mapping unicode table). You can use ranges as well, but
it will be faster for the queries if you actually have all the characters, and not just range.
For example this table (I added English and Hebrew... Do the same with all the languages that you need):
create table UnicodeMapping (Charecter nchar(1), UnicodeNum int, CultureN NVARCHAR(100), CollateN NVARCHAR(100))
GO
-- fill the table with main Hebrew characters, using a number table
insert UnicodeMapping (Charecter, UnicodeNum, CultureN, CollateN)
select NCHAR(n), n, 'He-IL', 'Hebrew_CI_AS'
from _ArielyAccessoriesDatabase.dbo.ArielyNumbers
where
n between 1488 and 1514 -- Hebrew
or n between 64304 and 64330 -- Hebrew
GO
-- fill the table with main English characters, using a number table
insert UnicodeMapping (Charecter, UnicodeNum, CultureN, CollateN)
select NCHAR(n), n, 'En-US', 'SQL_Latin1_General_CP1_CI_AS'
from _ArielyAccessoriesDatabase.dbo.ArielyNumbers
where
n between 97 and 122 -- En
or n between 65 and 90 -- En
GO
-- Do the same with all the languages that you need, and all the UNICODE ranges for those languages
select * from UnicodeMapping
GO
Step 2: You can create a function which get NVARCHAR as input and return the culture as output, or work directly on the data using JOIN your table and this table.
Assuming that each row is in specific language, In order to recognize the language, you just need to check 1 character from the original string (a text character and not a number for example which might be in any language) and examine which language this
single character is, using the our UnicodeMapping.
You can check this thread to see an implementation of this idea: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/ccc1d16f-926f-46c8-8579-b2eecf661e7c/sort-miultiple-language-data-in-sql-serevr-by-collation?forum=transactsql
* dont forget to add to the table all the characters like numbers and chose them as your default language
* in the link above I just select the first character using LEFT, but if the text start with number for example then you will get default language. If you sure that the text must start with real language character then it is best solution, but if not, than
It is better to use a "user defined function" which will find the first character that is not in the default language. if the function do not find any char in non-default language than it return default language, else it check the language using
the UnicodeMapping and return it.
Ronen Ariely
[Personal Site] [Blog] [Facebook] -
Query Locks Table in SQL Server 2000!!
Hi all!
I am facing a strange problem. I am using MS SQL Server 2000.
I have a JDBC program.It executes a query on a table (STUDENT) and fetches some record from it.
The query gets executed fine for the first time but when the SELECT query is executed on the same table (i.e. STUDENT) from some other block of code within the same program the program hangs at the location where resultset is pointed to the first record i.e. RS.next();
When I try to execute the SELECT query on the same table (i.e. STUDENT) from a query tool when the program is running it also gets hanged!!!
It seems that after running the query for the first time on the STUDENT table from the next time its getting hanged....i believe the Table gets locked for some reason!!
Is that normal with SQL Server 2000.....The same code works fine with other database!
Please suggest...wht has to b done to gt it fixed!
Thankz a loadz bforehand!
ArunBy default (transaction isolation level TRANSACTION_READ_COMMITTED ), SQL Server applies a shared read lock when you do a SELECT. This is should not prevent other selects on the same row / page but it will prevent updates / deletes.
I found a link that explains SQL Server locking: http://databasejournal.com/features/mssql/article.php/3289661 -
Create a table in SQL with datatype equivalent to LongBlob
I have a mySQL or phpMyadmin table (nor sure) (with longblob fields) that I want to convert to SQL Server.
Here is a link to a Rar with two files, the 'ORIGINAL CODE.sql' is the original code sample and the 'NEW_SQL_CODE.sql' is the code I am writing in SQL to create a database.
Click to download the two files.
I fail to make the insert in the 'NEW_SQL_CODE.sql', it says (translated from spanish) something like "The binary data will be truncated"
INSERT INTO inmuebles_fotos (ci_inm, pos, foto, mini, comentario, inet, impr_cartel, impr_visita) VALUES
(6, 0, 0xffd8ffe000104a46494600010100000100010...etc...
I don’t know how if I have defined the wrong data type (image) equivalent to the MySQL LongBlob. All I want to do is to make that insert in SQL and save that image as jpg if possible. I don't know if it's not posible in SQL and can only
be done in MySQL.
Thanks for any help.The original table is not mine; I am just trying to save the images as .jpg in hard drive.
Here is the original table I have that has 500Mb in pictures, in the sample there is only 1 picture:
CREATE TABLE IF NOT EXISTS `inmuebles_fotos` (
`ci_inm` int(10) unsigned DEFAULT NULL,
`pos` smallint(6) DEFAULT NULL,
`foto` longblob,
`mini` longblob,
`comentario` varchar(100) DEFAULT NULL,
`inet` tinyint(3) unsigned DEFAULT '0',
`impr_cartel` smallint(6) DEFAULT '0',
`impr_visita` smallint(6) DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
And here is the equivalent table in SQL that I am trying to create to import al registers so I can save the pictures from SQL Server that is what we use here.
CREATE TABLE [dbo].[inmuebles_fotos2](
[ci_inm] [int] NULL,
[pos] [int] NULL,
[foto] [image] NULL,
[mini] [image] NULL,
[comentario] [varchar](1) NULL,
[inet] [int] NULL,
[impr_cartel] [int] NULL,
[impr_visita] [int] NULL
Sorry for the trouble, I am trying everything I get my hands on until I get to save those images in “0x1234567890ABCDE…….” Format.
I'll try anything you sugest me but I have only use SQL Server so that's why I'm trying this road first.
Thanks for your help. -
View for a network node or link table
Can a view be used for a nework node or link table? The process sdo_net.validate_network hangs when I try to validate a network based on views for the node and link tables.
I am using a logical model. The sql statement (checking link/node relationship) that hangs is:
select count(a.link_id) from vlinks a
where not exists
select * from vnodes b
where b.node_id = a.start_node_id or b.node_id = a.end_node_id
I gather there is a concurrency issue with my links view because it joins a table with itself. I have a link table that has the start and end nodes defined on two records. Here is my view script:
create or replace view vlinks
(link_id, link_name, start_node_id, end_node_id, link_type, active, link_level, cost, parent_link_id)
as
select a.id, 'Link '||a.id, a.nodeid, b.nodeid, 'simple', 'Y',1,0,''
from vnodes a, vnodes b
where a.seq=1 and b.seq>1 and a.id = b.id
I can create tables from my views and validate them successfully through sdo_net.validate_nodes_schema, sdo_net.validate_links_schema, and sdo_net.validate_network.
I can analyze the network model through the Java API using the reachable nodes, shortest path, and spanning tree methods without any problems.
I guess I'll validate my view links by counting the total number of links and subtracting the number of links joined successfully at the start and end nodes - if 0 then all links are valid. E.g.:
select count(link_id) from
select link_id from vlinks
minus
select a.link_id from vlinks a, vnodes b, vnodes c
where a.start_node_id = b.node_id
and a.end_node_id = c.node_id -
OraOledb for 64-bit, Linked Servers and SQL Server 2005 issues
Our environment is : SQL Server 2005, Windows Server 2003, 64-bit and 32-bit operating systems.
Problem on 64-bit operating system box: (32-bit works fine).
I am trying to access Oracle 10g database using linked server from our SQL Server 2005. In case of number fileds i got the following error:
Invalid data for type "numeric".
After going through one of the posting in this forumn i was able to resolve the problem by converting those column values to char while querying and then converting them back to numeric type on SQL server side.
But today i ran into another problem. There is a VARCHAR2 column. I was able to retrieve the data yesterday for that column but today i am getting a blank recordset. If i exclude the colum from the query then i am getting all the rows.
I am querying against a view and it has got a number of columns whose data type is VARCHAR2.
Again the problem is on 64-bit operating system only. We have a 32-bit operating system on which i am able to retrieve the data including this column. I looked at the data and everything looks OK. No funny characters etc.
I tried workarounds like using cast, to_char, checking for nulls etc., Nothing works.
Any help is greately appreciated. Thanks.Did you find a resolution for this? We have similar problem. Set up a linked server in SQL 2006 to Oracle (running on Windows 64-bit) Linked server works and views I had set up were working but they added some new data in the Oracle test database I am using and now I get errors on one of the views.
Error I am getting on the view is "Cannot initialize the data source object of OLE DB Provider "OraOLDEDB.ORacle" for the linked server"
If I fine tune my queries to find the specific table or view that is at issue, then I get the error "inconsistent metadata for a column" -
How to see the linked table in oracle 8.0
hi,
i am using oracle 8.0, i have some 8 to 9 tables in it, some of them are linked, is there any way i could see the linked tables, if you do know any utility pls let me know.
regards
user456932i am using oracle 8.0, i have some 8 to 9 tables in
it, some of them are linked, is there any way i could
see the linked tablesI understand from your question that you are refering to Referential Integrity. I.e you have Parent Tables with Primary Keys and Child Tables linked with Foreign Keys.
It is easier to use GUI tools (OEM, Toad etc) to browse through them. In Toad for instance as a start, you can view the SQL Model. There are other Modelling tools you can use as well.
For the start, you can check USER_CONSTRAINTS and other related dictionary views to find them.
Here is a small example:
select constraint_name
,constraint_type
,table_name
,r_constraint_name
,delete_rule
,status
from user_constraints;
The constraint_type will show P (Primary Key), C (Check), R (Referential) etc
However, you can use queries to find Object Dependencies in the Database.
Read more from the SQL Reference Manual to get more knowledge in this area. -
Defining Dimensions, Attribute Hierarchies for a Link Table(Many to Many)
I have 3 Tables in the Database
Table 1: Transactions (Fact Table) - PK(TransactionId)
Table 2: Relationship (Dimension1) - PK(Relationship Id), FK_TransactionId, FK_CompanyId, RelationshipType
Table 3: Companies (Dimension 2) - PK(CompanyId)
Table 2: Relationship table is a link table between Transactions & Companies to facilitate many to many relationship.
I defined Fact and Dimension tables accordingly but having issues defining Dimension & Attributes for Relationship tables
Relationship Dimension:
I have 3 hierarchy groups defined
Hierarchy 1 - Relation -Relationship Type,Relationship Id(PK)
Hierarchy 2 - Transaction - Transaction, Relationship Id(PK)
Hiearchy 3 - Company - CompanyId, Relationship Id(PK)
Defined the attribute relationship in the following way
RelationshipID(PK) ---> CompanyId , RelationshipID(PK) ---> TransactionId, RelationshipID(PK)
---> RelationshipTYpe
I am getting incorrect results when I deploy the cube. Not all the types are being displayed only 4 types are being displayed out of 27 types though there exists Transactions for all the Types.
To fix the incorrect results, I tried to break the Relationship Dimension into 2 dimensions seperating Transaction(Relationship Dim) & Company,Type (Companies Dim). I tried to configure a many
to many Relationship type between my Companies Dim & Fact Table Transaction. But I get the error that says
"Companies Dim many to many dimension in the Tansaction measure group requires that the granularity of the Relationship dimension is lower than that of the Relationship measure group "
Any help regarding how to difine Dimensions & Attribute Hierarchies on a Many to many link table is appreciated.Hi Jaya,
According to your description, you are experiencing the issue when implement many to many relationship by using a bridge table in your SQL Server Analysis Services project, right?
Generally, a bridge table will have a surrogate key for the dimension and a surrogate key to the fact table or a degenerate dimension based on the fact table. Here are some blogs which describe how to implement many to many relationship using a bridge
table.
http://bifuture.blogspot.com/2011/06/ssaskimball-modeling-nm-relation.html
http://www.sqlchick.com/entries/2012/1/22/data-modeling-tip-when-using-many-to-many-bridge-tables-in-s.html
http://social.technet.microsoft.com/wiki/contents/articles/22202.a-practical-example-of-how-to-handle-simple-many-to-many-relationships-in-power-pivotssas-tabular-models.aspx
Regards,
Charlie Liao
TechNet Community Support -
I connect to a remote db using odbc connection. All the
tables in the db are linked and I am able to write my CF code to
read the tables and produce reports, etc. Now another person has
gone directly into Access and created a query with some of the
linked tables, and with data from an excel spreadsheet. Since the
query is already built and runs, they want me to take the query and
put it in a CF application so that CF can run it. I am able to
create a table (not linked) in the db and import the data from
excel to populate the table, but when I run CF with the query, it
does not like the table that I created, which I named tblSS_PO.
Here is the error :
Error Diagnostic Information
ODBC Error Code = S0002 (Base table not found)
[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object
name 'tblSS_PO'.
Does it not like it because the table I built is not linked
and not part of the original db ? Anyone with any ideas on how I
can solve this problem ? It seems like the data from excel will be
a consistent thing, all I need to do is plug it in each time and
run the query but I cannot get it to work. Thanks for any help.You have to have the same version of the access file on the
remote server
(one CF is connecting to) as you have on your local system.
Just changing
your local access file does not change the remote file. you
have to upload
your Access file just like you have to upload your site
pages.
Bryan Ashcraft (remove brain to reply)
Web Application Developer
Wright Medical Technology, Inc.
Macromedia Certified Dreamweaver Developer
Adobe Community Expert (DW) ::
http://www.adobe.com/communities/experts/
"trojnfn" <[email protected]> wrote in
message
news:ed7kjs$sbo$[email protected]..
>I thought I was putting the table and query in the db.
Like I said, I bring
>up
> Access and open the db and all the tables are there,
even the new one I
> created
> and the query (along with all the other queries) in the
query panel, so it
> looks like they are there. Yet when I run my cf query
with the dsn for the
> db,
> it says the table and query cannot be found. Could it be
that I am really
> connecting to a copy of the db and not the actual db
itself, thus it looks
> like
> it is there but not, since the dsn is to the remot db ?
I am just grasping
> at
> straws here, do not know what is happeng. If I create a
completely
> differenet
> db with the table, will cf allow for two different dsn
at once so that the
> tables from two different dbs can be linked ?
>
>
Maybe you are looking for
-
Need some help with ArrayLists...
Hello, I am having trouble implementing the code requested by the following questions: 1. Suppose an ArrayList holds Comparable objects. Write a method that removes the smallest value from such a list. 2. Implement Selection Sort for an ArrayList of
-
Hi, can you help me with this error: import java.util.*; import java.lang.*; public class ArrayAsParameter static final int ARRAY_SIZE = 10; static Scanner console = new Scanner(System.in); public static void ma
-
Migrate CAL's Terminal Licensing to Another TS Server on New Domain
Hi I have Terminal Server Licensing with Windows Server 2003 on OLD forest (tsserver.fortestold), on new forest I have Terminal Server Licensing with Windows Server 2003 Installed (tsserver.fortestnew). I want to migrate my CAL licenses from the old
-
LDOMS - virtual disks export mutiple times to different guest domains
Experts, From control domain, can I export one storage LUN to two guest domains? ldm add-vdsdev /dev/dsk/c1t5d0s0 disk1@primary-vds0 ldm add-vdisk disk1 disk1@primary-vds0 ldom1 Ok ldm add-vdsdev /dev/dsk/c1t5d0s0 disk2@primary-vds0 Gives error. With
-
Hi, I upgraded my Vista x64 (Dell Optiplex 755) to Windows 7 RTM and I'm getting the above bug check. The following site nicely describes the various bug check parameters - http://msdn.microsoft.com/en-us/library/ms796150.aspx - but I don't see an en