Showing posts with label linked. Show all posts
Showing posts with label linked. Show all posts

Monday, March 26, 2012

reg linked server


We are using linked servers to access another server, we are using windows authentication. but when we use

EXEC master.dbo.sp_addlinkedserver @.server = 'SERVER', @.srvproduct=N'SQL Server'

EXEC master.dbo.sp_addlinkedsrvlogin @.rmtsrvname = 'SERVER', @.locallogin = NULL, @.useself = N'False', @.rmtuser = N'sa', @.rmtpassword = N'sa'

When we connect using a SQL login as specified in the above line we are able to connect to the linked server.

But when we want to connect using a Windows user it is connecting.(we want to connect using a specific windows user i.e only one windows user will be there in the server and we shall access the server using that windows user)

EXEC master.dbo.sp_addlinkedsrvlogin @.rmtsrvname = 'SERVER', @.locallogin = NULL, @.useself = N'False', @.rmtuser = N'Domain\userid', @.rmtpassword = 'password'

Is there any other way to connect to the linked serrver.. we dont want to use the SQL server login to connect to the linked server.. how to use windows authentication to connect to the linked server. Anyone have tried it out.. Thanks in advance

It should work try the following example...

EXEC sp_addlinkedserver @.server = 'SERVER', @.provider = 'SQLOLEDB.1', @.srvproduct = '', @.provstr = 'Privider=SQLOLEDB.1;Data Source=TargetServer;Initial Catalog=Database'

go

Exec sp_addlinkedsrvlogin @.rmtsrvname = 'SERVER', @.useself = true, @.locallogin = null, @.rmtuser = 'Domain\Userid', @.rmtpassword = 'Password'

go

Select * From OpenQuery(MyRemoteServer, 'Select * From Sysobjects')

--OR

Select * From MyRemoteServer.DatabaseName.dbo.Sysobjects

go

Exec sp_droplinkedsrvlogin 'SERVER', null

Exec sp_dropserver 'SERVER'

Refreshing Links in Access doesn't allow me to Add Records!

Hi
I have an application in Access2003 with linked tables. When I create the
links manually (picking DNS etc) I have no problems. When I then try to
recreate the links programatically (different users) I am not able to add an
y
records to any of the tables! If I erase all the linked tables and reconnect
manually with the other user I have no problems!
I am using the relink code from
http://support.microsoft.com/defaul...kb;en-us;159691
Any and all suggestions Welcome!!!
Regards
Meir
Suggestions?There is a seperate newgroup for acceess/adp/sql server integration.
Post there
--
Regards
R.D
--Knowledge gets doubled when shared
"mrrcomp" wrote:

> Hi
> I have an application in Access2003 with linked tables. When I create the
> links manually (picking DNS etc) I have no problems. When I then try to
> recreate the links programatically (different users) I am not able to add
any
> records to any of the tables! If I erase all the linked tables and reconne
ct
> manually with the other user I have no problems!
> I am using the relink code from
> http://support.microsoft.com/defaul...kb;en-us;159691
>
> Any and all suggestions Welcome!!!
> Regards
> Meir
>
> Suggestions?
>|||As long as the user has permissions in the database and you have a
primary key defined on the table, inserts an dupdates shouldn't be a
problem. However, instead of using a DSN, you can supply connection
information in your code. This should get you started:
Public Sub LinkODBConnectionString()
Dim strConnection As String
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Set db = CurrentDb
' Specify the driver, the server, and the connection
strConnection = "ODBC;Driver={SQL Server};" & _
" Server=(local);Database=SqlDbName;Truste
d_Connection=Yes"
' Specifying a SQLS user/password instead of integrated security
' strConnection = "ODBC;Driver={SQL Server};" & _
' " Server=(Local);Database=SqlDbName;UID=Us
erName;PWD=password"
' Create Linked Table. The LinkedTableName and the
' ServerTableName can be the same.
Set tdf = db.CreateTableDef("LinkedTableName")
tdf.Connect = strConnection
tdf.SourceTableName = "ServerTableName"
db.TableDefs.Append tdf
Set tdf = Nothing
End Sub
On Fri, 7 Oct 2005 05:17:03 -0700, "mrrcomp"
<mrrcomp@.discussions.microsoft.com> wrote:

>Hi
>I have an application in Access2003 with linked tables. When I create the
>links manually (picking DNS etc) I have no problems. When I then try to
>recreate the links programatically (different users) I am not able to add a
ny
>records to any of the tables! If I erase all the linked tables and reconnec
t
>manually with the other user I have no problems!
>I am using the relink code from
>http://support.microsoft.com/defaul...kb;en-us;159691
>
>Any and all suggestions Welcome!!!
>Regards
>Meir
>
>Suggestions?sql

Friday, March 23, 2012

Refresh Linked Server without restart?

Hi All,

Firstly, apologies if this isn't the correct category for this posting but I couldn't see anything more appropriate!

I have an alias set up on my server which I want to change to point to a different server. However when I do this, the original info seems to be cached within SQL Server so any connections that were open before the change continue to use the original server. The only CONSISTENT way (that I can see) of ensuring the new attributes are picked up is by restarting the server which is a little more extreme than I would have hoped. It's worth mentioning that on a couple of occasions the updates have seemed to have filtered through without a restart which has only caused me more confusion due to this inconsistency...

If anyone knows of a handy sp or the likes that forces the linked server attributes to be refreshed I'd be mighty grateful.

Thanks in advance,

Rob.

Probably too late, but I thought it worth posting for others who may run into this:

- Change your alias
- Open SMSS and connect to the server with the linked server
- Open Server Objects -> Linked Servers -> your linked server
- Select Catalogs, and right-click "Refresh"

On my machine, this instantly corrected the cached alias value.

Tuesday, March 20, 2012

Referencing tables on a remote server

I have multiple stored procedures which include queries that reference tables
on a remote, linked server. For example,
select id, name from remoteserver.db.dbo.table1
In order to speed up my queries and avoids lockouts while data is being
inserted into those remote tables, I would like to use the WITH (NOLOCK)
clause. However, i cannot use that on remote tables. I thought of creating
local views for each of those remote tables, for example,
create view v_table1 as select id, name from remoteserver.db.dbo.table1
and then using that view instead of the original table in my queries. Would
this be faster? Most of my queries involve multiple tables. The remote
tables do not have primary keys, though they do have multiple indexes.
I should add that I do not have permission to change anything on the remote
server. That includes adding stored procedures to that remote database or
adding indexes or keys.
Also, the remote database is massive, multi-terrabytes massive. The tables
I am interested in have millions of rows.
In a related question, when you create a view that references tables on a
remote server, how quickly/often does it get updated when the data in those
tables gets changed? Am I creating a CPU burden on the remote server or only
my own? My application does not insert/update/delete data on the remote
server, only queries it. On the remote server, however, there is a great
deal of data insertion going on throughout the day and night.
Any suggestions?
Hi
A view does not copy data between servers, it is just a way at looking at
the data in table/tables.
If you create a view, the data, meeting the criteria, still has to be pulled
from the other server to be joined on the local server.
Think of a view as a Window to the other data.
Cheers
Mike
"speegee" wrote:

> I have multiple stored procedures which include queries that reference tables
> on a remote, linked server. For example,
> select id, name from remoteserver.db.dbo.table1
> In order to speed up my queries and avoids lockouts while data is being
> inserted into those remote tables, I would like to use the WITH (NOLOCK)
> clause. However, i cannot use that on remote tables. I thought of creating
> local views for each of those remote tables, for example,
> create view v_table1 as select id, name from remoteserver.db.dbo.table1
> and then using that view instead of the original table in my queries. Would
> this be faster? Most of my queries involve multiple tables. The remote
> tables do not have primary keys, though they do have multiple indexes.
> I should add that I do not have permission to change anything on the remote
> server. That includes adding stored procedures to that remote database or
> adding indexes or keys.
> Also, the remote database is massive, multi-terrabytes massive. The tables
> I am interested in have millions of rows.
> In a related question, when you create a view that references tables on a
> remote server, how quickly/often does it get updated when the data in those
> tables gets changed? Am I creating a CPU burden on the remote server or only
> my own? My application does not insert/update/delete data on the remote
> server, only queries it. On the remote server, however, there is a great
> deal of data insertion going on throughout the day and night.
> Any suggestions?
>

Referencing tables on a remote server

I have multiple stored procedures which include queries that reference tables
on a remote, linked server. For example,
select id, name from remoteserver.db.dbo.table1
In order to speed up my queries and avoids lockouts while data is being
inserted into those remote tables, I would like to use the WITH (NOLOCK)
clause. However, i cannot use that on remote tables. I thought of creating
local views for each of those remote tables, for example,
create view v_table1 as select id, name from remoteserver.db.dbo.table1
and then using that view instead of the original table in my queries. Would
this be faster? Most of my queries involve multiple tables. The remote
tables do not have primary keys, though they do have multiple indexes.
I should add that I do not have permission to change anything on the remote
server. That includes adding stored procedures to that remote database or
adding indexes or keys.
Also, the remote database is massive, multi-terrabytes massive. The tables
I am interested in have millions of rows.
In a related question, when you create a view that references tables on a
remote server, how quickly/often does it get updated when the data in those
tables gets changed? Am I creating a CPU burden on the remote server or only
my own? My application does not insert/update/delete data on the remote
server, only queries it. On the remote server, however, there is a great
deal of data insertion going on throughout the day and night.
Any suggestions?Hi
A view does not copy data between servers, it is just a way at looking at
the data in table/tables.
If you create a view, the data, meeting the criteria, still has to be pulled
from the other server to be joined on the local server.
Think of a view as a Window to the other data.
Cheers
Mike
"speegee" wrote:
> I have multiple stored procedures which include queries that reference tables
> on a remote, linked server. For example,
> select id, name from remoteserver.db.dbo.table1
> In order to speed up my queries and avoids lockouts while data is being
> inserted into those remote tables, I would like to use the WITH (NOLOCK)
> clause. However, i cannot use that on remote tables. I thought of creating
> local views for each of those remote tables, for example,
> create view v_table1 as select id, name from remoteserver.db.dbo.table1
> and then using that view instead of the original table in my queries. Would
> this be faster? Most of my queries involve multiple tables. The remote
> tables do not have primary keys, though they do have multiple indexes.
> I should add that I do not have permission to change anything on the remote
> server. That includes adding stored procedures to that remote database or
> adding indexes or keys.
> Also, the remote database is massive, multi-terrabytes massive. The tables
> I am interested in have millions of rows.
> In a related question, when you create a view that references tables on a
> remote server, how quickly/often does it get updated when the data in those
> tables gets changed? Am I creating a CPU burden on the remote server or only
> my own? My application does not insert/update/delete data on the remote
> server, only queries it. On the remote server, however, there is a great
> deal of data insertion going on throughout the day and night.
> Any suggestions?
>|||OPENQUERY will solve your problem. Examples:
--This will fail:
select * from server1.bb01_db.dbo.bb01 (nolock)
where process_dt = '2002-12-02' and mid = '03301001' and
tran_dt = '2002-12-02'
--This will work if you have your linked servers set up --
correctly:
select * from openquery(server1, 'select * from
bb01_db.dbo.bb01 (nolock)
where process_dt = ''2002-12-02'' and mid = ''03301001''
and tran_dt = ''2002-12-02''')
.
>--Original Message--
>I have multiple stored procedures which include queries
that reference tables
>on a remote, linked server. For example,
>select id, name from remoteserver.db.dbo.table1
>In order to speed up my queries and avoids lockouts while
data is being
>inserted into those remote tables, I would like to use
the WITH (NOLOCK)
>clause. However, i cannot use that on remote tables. I
thought of creating
>local views for each of those remote tables, for example,
>create view v_table1 as select id, name from
remoteserver.db.dbo.table1
>and then using that view instead of the original table in
my queries. Would
>this be faster? Most of my queries involve multiple
tables. The remote
>tables do not have primary keys, though they do have
multiple indexes.
>I should add that I do not have permission to change
anything on the remote
>server. That includes adding stored procedures to that
remote database or
>adding indexes or keys.
>Also, the remote database is massive, multi-terrabytes
massive. The tables
>I am interested in have millions of rows.
>In a related question, when you create a view that
references tables on a
>remote server, how quickly/often does it get updated when
the data in those
>tables gets changed? Am I creating a CPU burden on the
remote server or only
>my own? My application does not insert/update/delete
data on the remote
>server, only queries it. On the remote server, however,
there is a great
>deal of data insertion going on throughout the day and
night.
>Any suggestions?
>.
>

referencing linked server in stored procedures

hello, i need to reference a table in a sqlserver instance from a
stored procedure in a different sqlserverinsctance... it's possible
reference the table from the stored procedure?
Did you try using full naming:
servername.database.owner.Tablename
MC
"hongo32" <hongo32es@.yahoo.com> wrote in message
news:1133304999.836436.40130@.g49g2000cwa.googlegro ups.com...
> hello, i need to reference a table in a sqlserver instance from a
> stored procedure in a different sqlserverinsctance... it's possible
> reference the table from the stored procedure?
>

referencing linked server in stored procedures

hello, i need to reference a table in a sqlserver instance from a
stored procedure in a different sqlserverinsctance... it's possible
reference the table from the stored procedure?Did you try using full naming:
servername.database.owner.Tablename
MC
"hongo32" <hongo32es@.yahoo.com> wrote in message
news:1133304999.836436.40130@.g49g2000cwa.googlegroups.com...
> hello, i need to reference a table in a sqlserver instance from a
> stored procedure in a different sqlserverinsctance... it's possible
> reference the table from the stored procedure?
>

referencing linked server in stored procedures

hello, i need to reference a table in a sqlserver instance from a
stored procedure in a different sqlserverinsctance... it's possible
reference the table from the stored procedure?Did you try using full naming:
servername.database.owner.Tablename
MC
"hongo32" <hongo32es@.yahoo.com> wrote in message
news:1133304999.836436.40130@.g49g2000cwa.googlegroups.com...
> hello, i need to reference a table in a sqlserver instance from a
> stored procedure in a different sqlserverinsctance... it's possible
> reference the table from the stored procedure?
>

Friday, March 9, 2012

Reference Linked Server From Linked Server

Hello all, hoping someone can help.
usual info: windows 2003,sql server 2005 32bit and 64bit
ServerA has a linked server defined that points to ServerB.
ServerC has a linked server defined that points to ServerA.
Is it possible to have a query execute on ServerC that will reference
ServerB through the linked ServerA?
example:
execute on ServerC: Select * from ServerA.ServerB.database.dbo.table
Note:
I understand that I can use openquery:
Select * from openquery(ServerA,'Select * from
ServerB.database.dbo.table')
But because I need to use openquery in the query executed on ServerB
it will get ugly.
Example:
Select * from openquery(ServerA,'Select * From openquery(ServerB,
''Select * from database.dbo.table''')
You may be wondering why I don't just create linked server on ServerC
that references ServerB directly. Let me explain:
ServerC is 64bit SQL Server2005
ServerA is 32bit SQL Server2005
ServerB is 32bit Intersytems Cache Database (ODBC Driver ONLY!)
ServerA uses the oledb provider for ODBC datasources to connect to
ServerB. Intersystems does not have an oledb driver. And Microsoft
does not support the oledb provider for odbc datasourceS on 64 bit sql
server.
Any and all ideas are welcome!
Jay
I don't believe this is possible using T-SQL without OPENQUERY or similar.
Would creating views on ServerA that refer to ServerB help? I can't say I
particularly like this approach, but it may be an option.
Stored procedures would be a more fitting approach to take if your querying
is not ad-hoc.
"Jay" <JasonPirtle@.gmail.com> wrote in message
news:8325615c-a36b-4722-9974-a9b58d4756c6@.i12g2000prf.googlegroups.com...
> Hello all, hoping someone can help.
> usual info: windows 2003,sql server 2005 32bit and 64bit
> ServerA has a linked server defined that points to ServerB.
> ServerC has a linked server defined that points to ServerA.
> Is it possible to have a query execute on ServerC that will reference
> ServerB through the linked ServerA?
> example:
> execute on ServerC: Select * from ServerA.ServerB.database.dbo.table
> Note:
> I understand that I can use openquery:
> Select * from openquery(ServerA,'Select * from
> ServerB.database.dbo.table')
> But because I need to use openquery in the query executed on ServerB
> it will get ugly.
> Example:
> Select * from openquery(ServerA,'Select * From openquery(ServerB,
> ''Select * from database.dbo.table''')
> You may be wondering why I don't just create linked server on ServerC
> that references ServerB directly. Let me explain:
> ServerC is 64bit SQL Server2005
> ServerA is 32bit SQL Server2005
> ServerB is 32bit Intersytems Cache Database (ODBC Driver ONLY!)
> ServerA uses the oledb provider for ODBC datasources to connect to
> ServerB. Intersystems does not have an oledb driver. And Microsoft
> does not support the oledb provider for odbc datasourceS on 64 bit sql
> server.
> Any and all ideas are welcome!
> Jay
>

Reference Linked Server From Linked Server

Hello all, hoping someone can help.
usual info: windows 2003,sql server 2005 32bit and 64bit
ServerA has a linked server defined that points to ServerB.
ServerC has a linked server defined that points to ServerA.
Is it possible to have a query execute on ServerC that will reference
ServerB through the linked ServerA?
example:
execute on ServerC: Select * from ServerA.ServerB.database.dbo.table
Note:
I understand that I can use openquery:
Select * from openquery(ServerA,'Select * from
ServerB.database.dbo.table')
But because I need to use openquery in the query executed on ServerB
it will get ugly.
Example:
Select * from openquery(ServerA,'Select * From openquery(ServerB,
''Select * from database.dbo.table''')
You may be wondering why I don't just create linked server on ServerC
that references ServerB directly. Let me explain:
ServerC is 64bit SQL Server2005
ServerA is 32bit SQL Server2005
ServerB is 32bit Intersytems Cache Database (ODBC Driver ONLY!)
ServerA uses the oledb provider for ODBC datasources to connect to
ServerB. Intersystems does not have an oledb driver. And Microsoft
does not support the oledb provider for odbc datasourceS on 64 bit sql
server.
Any and all ideas are welcome!
JayI don't believe this is possible using T-SQL without OPENQUERY or similar.
Would creating views on ServerA that refer to ServerB help? I can't say I
particularly like this approach, but it may be an option.
Stored procedures would be a more fitting approach to take if your querying
is not ad-hoc.
"Jay" <JasonPirtle@.gmail.com> wrote in message
news:8325615c-a36b-4722-9974-a9b58d4756c6@.i12g2000prf.googlegroups.com...
> Hello all, hoping someone can help.
> usual info: windows 2003,sql server 2005 32bit and 64bit
> ServerA has a linked server defined that points to ServerB.
> ServerC has a linked server defined that points to ServerA.
> Is it possible to have a query execute on ServerC that will reference
> ServerB through the linked ServerA?
> example:
> execute on ServerC: Select * from ServerA.ServerB.database.dbo.table
> Note:
> I understand that I can use openquery:
> Select * from openquery(ServerA,'Select * from
> ServerB.database.dbo.table')
> But because I need to use openquery in the query executed on ServerB
> it will get ugly.
> Example:
> Select * from openquery(ServerA,'Select * From openquery(ServerB,
> ''Select * from database.dbo.table''')
> You may be wondering why I don't just create linked server on ServerC
> that references ServerB directly. Let me explain:
> ServerC is 64bit SQL Server2005
> ServerA is 32bit SQL Server2005
> ServerB is 32bit Intersytems Cache Database (ODBC Driver ONLY!)
> ServerA uses the oledb provider for ODBC datasources to connect to
> ServerB. Intersystems does not have an oledb driver. And Microsoft
> does not support the oledb provider for odbc datasourceS on 64 bit sql
> server.
> Any and all ideas are welcome!
> Jay
>

Reference Dimension causing long processing times

I have a reference dimension that is linked to a regular dimension that is linked to the fact table. For some reason, when I process the database with some small sample data, it take about 5 minutes to process, where it should take 10 seconds. I am using a reference dimension because it is a child-parent hierarchy, and I don't think I can merge it into the regular dimension. My work-around is to just include the link to this reference dimension in the fact table, so I can create the child-parent dimension as regular. Now is processes in 10 seconds. It doesn't seem ideal since I have what seems to me an unessary dimension now.

If I turn "materialize" off, it processes in 10 seconds, but I don't know the implications of this.

Does anyone have any idea of what is going on or have any advice?

Thanks,

Ernie

Are you using a referenced dimension here because the parent column is in another table from the child column? If so, you could create a view on top of them that encapsulates the relationship. What are the other issues you see regarding not being able to merge these columns into a regular dimension?|||

Thanks for the reply Scott.

The child and parent are in the same view. I've created another dimiension because the child attribute has to be a key. The child attribute, or key of this dimension, is not what joins directly to the fact table. There is an intermediate "field" that has to create this link, which is a foriegn key in the regular dimension, which has a key to link to the fact table. Hmmm, did I say that right? I may not be explaining things well, as I'm a bit new at this. Anyway, this is why I "think" I can't merge them.

Maybe this is a valid example:

Fact table has column SubAccount

SubAccount table has Account column (multiple sub-accounts per account)

Account table has AccountParent column which created the child parent relationship.

In this example, I would create a regular SubAccount dimension and a reference dimension called Account. My "workaround" is to put both the Account and SubAccount columns in the Fact table (or view).

Ernie

|||

It sounds like you should merge the sub account and account into a single dimension (make it a parent-child). You'll use a snowflake schema which will describe the join between the account and sub account tables as a source for the dimension, yet only have a single dimension.

Without doing this, if you tried going down the road of having two account dimensions (subaccount and account), then you'd end up with cases where you would get confusing results (like subaccounts that are not really related to an account showing up together, etc.)

Hope that helps

|||

Scott (or anyone else):

I am running into a problem that seems to be related to the one described by Ernie above. Here is the situation:

1) I have a referenced dimension (dimA) that joins to the fact table (factB) through an intermediate dimension table (dimC).

2) The referenced dimension (dimA) has a parent-child heirarchy. The primary key of this table (keySelf) and the parent key (keyParent) are in the same table (dimA) i.e. the parent-child hierarchy is stored in the same table and not in a separate table.

3) I am able to deploy the cube and it gives correct results.

4) I am currently in the design stage so I am dealing with fairly small data sets. Therefore, I donot know if it is performing poorly during deployment.

5) My problem occurs when I try to design aggregations. I get the error at the end of the wizard when I am deploying the aggregations. The error is on the Measure group that is based on factB. The error states:

"Errors in the high-level relational engine. The binding for the 'standardId' column is not a ColumnBinding type."

Note that 'standardId' is the primary key (keySelf) in the dimA table. i.e. it is the key that maps factB to dimA (through dimC).

6) The error goes away if I uncheck the "Materialize" option in the Define Relationship window for the relationship between factB and dimA.

7) I have other referenced dimensions in the cube that relate to factB through dimC that do not have a parent-child hierarchy and they do not give this problem.

So it seems that if a referenced dimension has a parent-child hierarchy and is materialized then the aggregations run into problem. I realize that I can eliminate the issue by making dimA a regular dimension of factB but I am curious to understand why this is happening.

Is this expected behaviour or am I doing something wrong?

Thanks beforhand.

Regards,

Amardeep

|||

Amardeep, this sounds like it could be a bug that you're hitting. I'll forward this on to our test team to verify.

One thing you could do to work around the issue that you're seeing though (since not materializing the dimension will be slower at query time) would be to not use a referenced dimension and instead use a regular dimension. To do this you'll need to modify your data source view (DSV) to include additional relationships in order to allow the join to work properly.

Hope this helps.