Syntax To Access Database On Another Server
Feb 26, 2008I know how to access different tables on the same server by prefixing
the table with the database name. Is there anyway to prefix the
server name to link two tables across servers? Thanks.
I know how to access different tables on the same server by prefixing
the table with the database name. Is there anyway to prefix the
server name to link two tables across servers? Thanks.
I have used this query statement with a SQL Server 2005 database and need to use something similar with an Access database:
SELECT products.*, Category AS Expr1
FROM products
WHERE (Category = @Category)
When I test this in a table adapter there is no preview due to lack of parameter. I seem to recall that Access uses different syntax in the WHERE filter clause (i.e., not @). Can someone help me out with this?
MS SQL Server 2005 Express.
I'm trying to connect to Access DB (having System Database) via OPENROWSET.
Everything (client, server and access file) is on local drive.
This works (ODBC):
select *
from openrowset('MSDASQL',
'Driver={Microsoft Access Driver (*.mdb)};Dbq=C:MBK.mdb;SystemDB=C:SECURED.MDW;Uid=me;Pwd=pw;',
'select * from [Mbk]')
This works (Jet.OLEDB):
select *
from opendatasource('Microsoft.Jet.OLEDB.4.0',
'Data Source=C:MBK.mdb;Jet OLEDBystem Database=C:SECURED.MDW;User ID=me;Password=pw;')
...Mbk
This won't work (Jet.OLEDB):
select *
from openrowset('Microsoft.Jet.OLEDB.4.0',
'MS Access;Database=C:MBK.mdb;System Database=C:SECURED.MDW;UID=me;PWD=pw;',
'select * from [Mbk]')
saying ... "Wrong argument".
This won't work (Jet.OLEDB):
select *
from openrowset('Microsoft.Jet.OLEDB.4.0',
'MS Access;Database=C:MBK.mdb;SystemDB=C:SECURED.MDW;UID=me;PWD=pw;',
'select * from [Mbk]')
saying ... "There are no permissions for usage of object C:MBK.mdb". It seems that it simply hasn't found system database file C:SECURED.MDW, cause when I change SystemDB=C:SECURED.MDW to something like BlahBlahBlah=C:SECURED.MDW the same message is shown.
So, what is the right syntax for stating System Database in OPENROWSET query string? And why 'System Database' won't work?
Thank you.
This runs in Access, but SQL Server 7 complains that BETWEEN is unrecognized. Can anyone help me? thanks
SELECT yearId, IIf(Date() BETWEEN [qrtOneStart] AND [qrtOneEnd],1, IIf(Date() BETWEEN [qrtTwoStart] AND [qrtTwoEnd], 2, IIf(Date() BETWEEN [qrtThreeStart] AND [qrtThreeEnd], 3, 4))) AS CurrentQrt, yearName
FROM tblYear
Ok I am tying to convert access syntax to Sql syntax to put it in a stored procedure or view..
Here is the part that I need to convert:
SELECT [2007_hours].proj_name, [2007_hours].task_name, [2007_hours].Employee,
IIf(Mid([task_name],1,3)='PTO','PTO_Holiday',
IIf(Mid([task_name],1,7)='Holiday','PTO_Holiday',
IIf(Mid([proj_name],1,9) In ('9900-2831','9900-2788'),'II Internal',
IIf(Mid([proj_name],1,9)='9900-2787','Sales',
IIf(Mid([proj_name],1,9)='9910-2799','Sales',
IIf(Mid([proj_name],1,9)='9920-2791','Sales',
)
)
)
)
) AS timeType, Sum([2007_hours].Hours) AS SumOfHours
from................
how can you convert it to sql syntax
I need to have a nested If statment which I can't do in sql (in sql I have to have select and from Together for example ( I can't do this in sql):
select ID, FName, LName
if(SUBSTRING(FirstName, 1, 4)= 'Mike')
Begin
Replace(FirstNam,'Mike','MikeTest')
if(SUBSTRING(LastName, 1, 4)= 'Kong')
Begin
Replace(LastNam,'Kong,'KongTest')
if(SUBSTRING(Address, 1, 4)= '1245')
Begin
.........
End
End
end
Case Statement might be the solution but i could not do it.
Your input will be appreciated
Thank you
I am trying to get a SQL statement to work with both Access 2000 and SQL Server 2000.
The statement that works in SQL Server is:
---
UPDATE [myTable2]
SET
[myTable2].[FieldA] = 'Hello',
[myTable2].[FieldB] = 2,
[myTable2].[FieldC] = 'xxx',
[myTable2].[FieldD] = 0
FROM [myTable1] INNER JOIN
(myTable2 INNER JOIN [myTable3]
ON [myTable2].[FieldX]=[myTable2].[FieldY])
ON [myTable1].[FieldZ]=[myTable2].[FieldY]
WHERE ([myTable2].[FieldY]=1)
And ([myTable3].[FieldZ]='xxx');
---
(names have been changed to protect the innocent)
The statement that works in Access is:
---
UPDATE [myTable1] INNER JOIN
(myTable2 INNER JOIN [myTable3]
ON [myTable2].[FieldX]=[myTable2].[FieldY])
ON [myTable1].[FieldZ]=[myTable2].[FieldY]
SET
[myTable2].[FieldA] = 'Hello',
[myTable2].[FieldB] = 2,
[myTable2].[FieldC] = 'xxx',
[myTable2].[FieldD] = 0
WHERE ([myTable2].[FieldY]=1)
And ([myTable3].[FieldZ]='xxx');
---
It seems that neither will accept the other format. Can anyone suggest how I can rearrange the statement so that it works in both?
Where i try to create stored procedure in sql server 2000 using query analyzer i'm getting an error
'[Microsoft][ODBC SQL Server Driver]Syntax error or access violation'
and the same stored procedure if i try after some time without any changes it gets created..
how is wrong?
Hi guys! I am using SQL 2005 and I wonder why I am encountering the error "[Microsoft][ODBC SQL Server Driver]Syntax error or access violation" everytime I am trying to create stored procedure with temp table and table variable.
See my code below with temp table.
Any thoughts will be appreciated!
CREATE PROCEDURE DBO.SAMPLESP
(@DETAILS AS VARCHAR(8000),
@ID AS VARCHAR(15))
AS
BEGIN TRANSACTION
CREATE TABLE DBO.#TEMPTABLE
{
ASSET VARCHAR(50)
}
DECLARE @INSTINSERT AS NVARCHAR(4000)
SET @INSTINSERT= 'INSERT INTO #TEMPTABLE(ASSET)'
SET @INSTINSERT= @INSTINSERT+ @DETAILS
EXEC sp_ExecuteSQL @INSTINSERT
INSERT INTO InstDetail
(TrackNum, ASSETID)
SELECT @ID, A.ASSE
FROM #TEMPTABLE A
DROP TABLE #TEMPTABLE
IF @@ERROR != 0
BEGIN
ROLLBACK TRANSACTION
RAISERROR('There was an error in here', 11, 1)
RETURN
END
ELSE
COMMIT TRANSACTION
I have recently upgraded to SQL2014 on Win2012. The Access front end program works fine.
But, previously created Excel reports with built in MS Queries now fail with the above error for users with MS 2013. The queries still work for users still using MS 2007.
I also cannot create any new queries and get the same error message. If I log on as myself on the domain to another PC with 2007 installed it works fine, so I don't think it is anything to do with AD groups or permissions.
There is a JOIN syntax error in this SQL, but my slow brain cannot figure out where. I tried to join two queries, which had been successful. Problem occurred when I added second left join. Can anyone help?
PARAMETERS pstrFinYear Text ( 255 ), pintAdjMonth Long;
SELECT A.BudgetLineID, A.BudgetLine, B.NumIsDevelopBusinessInternationally, B.NumIsDeeperParticipation, B.NumIsNewExporter, B.NumProjects, C.NumCompanies, A.KMISReportOrder
FROM ( tblkpBudgetLine AS A
LEFT JOIN
[SELECT BudgetLineID, FinancialYear, SUM(IsDevelopBusinessInternationally) AS NumIsDevelopBusinessInternationally, SUM(IsDeeperParticipation) AS NumIsDeeperParticipation, (-1*SUM(AdjustedNewExpMonth=pintAdjMonth)) AS NumIsNewExporter, COUNT(ProjectID) AS NumProjects
FROM qryBoardReport_Actuals
WHERE FinancialYear=pstrFinYear
AND AdjustedProjectStartMonth=pintAdjMonth
GROUP BY BudgetLineID, FinancialYear]. AS B
ON (A.BudgetLineID=B.BudgetLineID) AND (A.FinancialYear=B.BudgetLine)
LEFT JOIN
[SELECT Z.BudgetLineID, Z.FinancialYear, Z.AdjustedProjectStartMonth, COUNT(Z.Company) AS NumCompanies
FROM [SELECT DISTINCT qryBoardReport_Actuals.BudgetLineID AS BudgetLineID, qryBoardReport_Actuals.FinancialYear AS
FinancialYear, qryBoardReport_Actuals.AdjustedProjectStartMonth, qryBoardReport_Actuals.CompanyID as Company
FROM qryBoardReport_Actuals
WHERE FinancialYear=pstrFinYear
AND AdjustedProjectStartMonth=pintAdjMonth
GROUP BY qryBoardReport_Actuals.FinancialYear, qryBoardReport_Actuals.BudgetLineID, qryBoardReport_Actuals.AdjustedProjectStartMonth, qryBoardReport_Actuals.CompanyID]. AS Z
GROUP BY FinancialYear, BudgetLineID, AdjustedProjectStartMonth] as C
ON (A.BudgetLineID=C.BudgetLineID) and (A.FinancialYear=C.FinancialYear))
WHERE A.FinancialYear=pstrFinYear
ORDER BY A.KMISReportOrder;
Dear All,
i have a question abt winCE 4.2 and SQL server CE.
i am using VB.net of Visual Studio 2005
My platform is using a PDA with winCE 4.2 and SQL server CE. The Host program is using dbf files on desktop side.
I got a problem of how to sync / read the sql CE data from a windows application.
so, i wanna ask,
1. any method to access the data from winCE data by windows application? or can i convert the sdf file to windows readable files? or any others?
2. Can i use a MDB to sync with SQL server CE?
can i synchronize the mobile device which has a SQL Server CE database with the Access database on the desktop?
last question,
3. is that windows CE .net 4.2 not support pocket access (cdb) anymore?
please help me out
I need detailed instructions on how to connect to a database from a Microsoft Access 2007 database to a Microsft Office Accounting 2007 database. The accounting database is an SQL 2005 datbase. It has an instance name of "MSSMLBIZ".
When I try I get an SQL error 53. Do not have permissions or database does not exist.
Thanks in advance for any help.,
I am trying to convert a code from access Db to sql code?
II(Left([dbo_ClaimLosstype].[dscr],4)="Liab","D_Liab","D_Property"),
I created a couple of stored procedures. One of them (let's call it SP1) dumps information into a table and then calls another stored procedure (SP2) to put the info in a temp table in crosstab format. SP1 then displays the info from the temp table.
When I execute SP1 from Query Editor, everything works perfectly. No errors are returned and my data is displayed just as expected.
When I try to execute SP1 from MS Access's pass-through query, I get the following error:
[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near ','.(#102)[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near 'A'(#102)
I've found that the error occurs when the SP2 is called from within SP1. If it's working fine in Query Editor, shouldn't it work from MS Access? Any insights?
Hi I am wondering if anyone knows of a way of synchroniseing two versions of a database one in access and one in sql server so they can both run in parrallel in ssis for updates etc.
Also can anyone recommend a book which is easy to use or resources as I can't find what I am looking for in the online help.
Thanks in advance
I am having trouble finding the correct syntax to access a variable. I have a variable defined in the Variables window: The variable name is formatedDate. The DataType is String.
I am successfully setting the value of the variable in a Execute SQL Task. The SQL is as follows:
SELECT LEFT(CONVERT(VARCHAR, MAX(ReportDate), 120), 10) as formatedDate
from DimReportDates
The Result Set is set to “Single Row” and properly set up.
No problem so far. I can see with a watch that the variable has the correct value, something like:
‘2015-09-30’
Now, in a subsequent step, a Data Flow Task, I want to access the variable. Actualy it is in the SQL statement of a OLE DB source in the Data Flow… I have the following:
Declare @sDate smalldatetime
SELECT @sDate = xxxxx
I have tried several things substituting xxxxx above, but nothing seems to work. One variation was
@[User::formatedDate])
Another was
((DT_WSTR, 10) @[User::formatedDate]).
I think I’m close, but just can’t get it. What is the correct syntax.
Dear Gurus,
I wanted to Synchronize the SQL Server (2005) Database to Ms-Access 2003. I want know how can I design the SSIS Package. Could anyone please advice me to design the package..?
Thanks
Krishna
We have been asked to look into using stored procedures with SQL Server 7.0 as a way to speed up a clients site. 99% of all the articles I have read along with all the books all say Stored Procedure should be used whenever possible as opposed to putting the SQL in your ASP script. However one of my colleagues has been speaking to Microsoft and they said that that they were surprised that our client wanted to use Stored Procedures as this was the old method of database access and that now he should really consider using COM objects for data access as itis much faster. Has anyone got any views on this or know of any good aticles regarding this matter ?
View 1 Replies View RelatedI want to import the data from specific Access Database and Table to SQL Server, using SQL Script. I am trying to implement the solution as given in this link. URL....Here is the code that I have tried -
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'Ad Hoc Distributed Queries', 1;
GO
[code]...
The access database file path is - 'C:SQL ProjectTestDB1001.mdb'.The Table from which I want to import the data is - [Table1001]. but when I run this script, I get this error -9 The OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "MSAccessConnect" reported an error. Authentication failed.
Secondly I need to make 2 more changes to the code posted above.
1.If some access database .mdb, has got password protection, then how to include the password in the script, so that one does not have to manually feed in the password during data import work.
2. How to limit the data that is to be imported from the table [Table1001] by including a WHERE Clause, like for example - SELECT * FROM [Table1001] WHERE xdate = '2015-9-16 00:00:00.000')
Hi.
I have a stored procedurein my database and I want to access table in other server. can I do that in Stored procedure?
Hi, i want to know, is it possible to access a database that is not on the local machine ?what if i want to access a databse that resides on another of my websites (on a different server) ?can any one help ?
View 1 Replies View RelatedWhen I open a new table in Access trough the ODBC database, it doesn't read the tables already exist.
The ODBC is rightly configured. I configured my client in Control Panel, but I can't convert in Access the tables in SQL.
We are upgrading from SQL 2008R2 to SQL2014 but we have discovered that a couple of our applications are not supported on 2014. We'd like to keep one 2008R2 server and one 2014 server until we have time to upgrade the applications and move everything to the new server. The problem is we have custom code in some of the 2014 databases that access tables in the 2008 databases.
I know we can easily do cross server joins by using a linked server, but it would be a huge undertaking to find all that code and add a linked server name in front of every table, stored procedure, etc. So my question is, is there any way to move a database to a different server and still be able to access it without having to qualify the object names with a linked server? Is there some kind of server/database synonym that can be setup that would be recognized by all databases?
I have a sql server database and i need to convert to Access, how can i do this using sql server?
View 4 Replies View RelatedHi,
We are planning to migrate data from access to sqlserver. I have good knowledge on sql server...but never used access to migrate. Can anyone help me with the basics to be kept in mind and methods and errors you get in migrateing data.If possible explain in detail and what is to be done while migrating data.....thank you in advance.And its urgent please.
Hi,
Can anyone please tell me how to access a SQL server database remotely. I have
the IP address and login info. of the NT machine that is running SQL server
database, and I want to access the data remotely.
Thanks for any help.
Chetan
Hello,
Is it possible to configure the web server to execute XML queries without installing SQL Client?
Thanks
Sejal
Hello SQL guys,
If possible to connect our remote server from my end ?.what r the possiblities is there.tell me some ideas,i already tried it to register our remote server database thru ODBC but it not connected properly but i ve tried in our intranet/network it's working fine.
Nellai
HELLO,
We are specializing on Migrating, Replicating, Synchronizing data and databases on Windows, Windows NT, Unix, AS/400 and legacy.
We deliver our software to migrate any data to MS SQL Server.
We are specialized to deliver DataMarts for any databases with :
a novative script and visual language VEXScript that you can play with W95, W98, WNT stand alone or with your prefered query tools or PC language
Independant database software vendors
Compatible XML (Q1 99)
Messaging interface ( MS Exchange, Lotus, Mapi, ......)
If you want visit our web site on www.dataexchanger.com and e-mail us to marketing@dataexchanger.com if you want ask us.
We will be pleased to enter in agreement with you.
Best Regards
Denis Schirra
Vice President Technical
CrossDataBase Technology
Decision support,Datawarehouse,DataExchange, DataSynchronization
Data Surfing is our mission
is it possible to convert an Access database to SQL Server 2005 or 2000?
View 3 Replies View RelatedHello!
I have a Java application that gains access to a SQL database using:
connection="jdbc:jtds:sqlserver://localhost:1433/databasename;user="+user+";password="+password;
//Load and register SQL Server driver
Class.forName("net.sourceforge.jtds.jdbc.Driver");
//Establish the connection
conn=DriverManager.getConnection(temp);
When I distribute this application throughout the local network, what would the jdbc url be for the application to find the SQL server?
Should I replace "localhost:1433" with something else?
The instance of SQL server is called SQLExpress.
I have my computer name, computer domain, ip address etc.
Is the port 1433 still the same?
How could the SQL database be located throughout the network?
Any advice appreciated.
I'm taking over an SQL Serverdatabase which is often updatedwith data from an Access database.Knowing little about either, thissimple task has become a challenge.I'm told that the previous personused to type some simple SQLcommands and this would updatethe SQL server database but thecommands have been lost and theprevious person is unavailable.The Access database has exactlythe same column names as the SQL-server databaseand it is something simplelike:Control ID Phone Name Address1 Address2Does anyone know the SQL commandsto do this kind of SQL server database update from theabove mentioned Access database?The previous person left an app which connectsthe two databases and leaves a placewhere the SQL commands are to be typed.ThanksTAK
View 2 Replies View Relatedif i can somehow load/copy a sql directory with mdf etc on pcs shipped to our customers with our app, but sql isnt installed/running on the shipped pc, can our customers' sql instances running on their existing machines "see/use" our shipped database, assuming the hard drive on the shipped pc can be made to look like a mapped/remote drive? We wonder about 2000 and 2005.
View 3 Replies View Related