Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 7,2000
»
T-SQL
»
Syntex Error in Distributed query
Syntex Error in Distributed query
Rate Topic
Display Mode
Topic Options
Author
Message
Nitin Gupta - SQL DBA
Nitin Gupta - SQL DBA
Posted Wednesday, November 11, 2009 1:17 PM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Thursday, March 28, 2013 3:06 AM
Points: 158,
Visits: 129
Hi All,
I'm try to connect multiple SQL server instances using distributed query ( OPENROWSET() ); whenever I'm executing connection string on its I'm getting syntex error on it.
set @conn= '''SQLOLEDB'', ''Server=' + @server +'; ''user id=' + @user id +'; ''Password=' +@pass'''
please correct me.
Thanks & Regards,
Nitin Gupta
SQl Server (7.0,2000,2005) - Sr. DBA
HCL Technologies, India
Post #817420
GSquared
GSquared
Posted Wednesday, November 11, 2009 1:35 PM
SSCoach
Group: General Forum Members
Last Login: 2 days ago @ 1:55 PM
Points: 15,442,
Visits: 9,571
Are you building the connection dynamically inside the OpenRowset command? Or are you dynamically building an OpenRowset command? I really can't tell what you're doing from the little bit you posted.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
Post #817429
Nitin Gupta - SQL DBA
Nitin Gupta - SQL DBA
Posted Wednesday, November 11, 2009 1:46 PM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Thursday, March 28, 2013 3:06 AM
Points: 158,
Visits: 129
Hi, Basically I'm preparing a script to get backup details of all my servers (124 Physical Boxes in a single domain),
Steps:
1. Passing veriable name in @server and storing that script into a variable @query.
2. passind that @query into openrowset();
but when I'm seting connect string in @query like
@query = 'provider string with trusted connection' its showing syntex error on @Password
Thanks & Regards,
Nitin Gupta
SQl Server (7.0,2000,2005) - Sr. DBA
HCL Technologies, India
Post #817435
Nitin Gupta - SQL DBA
Nitin Gupta - SQL DBA
Posted Wednesday, November 11, 2009 1:50 PM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Thursday, March 28, 2013 3:06 AM
Points: 158,
Visits: 129
Please find the same kind of code.
-- TO BE RUN ON SHCBBMS01 SERVER
-- For SQL 2000
set nocount on
go
declare @server varchar(256), @ctr int
declare @tbllist table (srvr varchar(256),id int identity)
insert @tbllist
select 'SHBAHYP01T' union
select 'SHBAHYP04' union
select 'SHBAINT02'
set @ctr = 1
while @ctr <= (select max(id) from @tbllist)
begin
select @server = srvr
from @tbllist
where id = @ctr
declare @conn varchar(200), @query varchar(8000), @sql varchar(8000)
set @conn= '''SQLOLEDB'', ''Server=' + @server +';Trusted_Connection=yes;'''
set @query = '''select @@SERVERNAME,name from master.sys.databases'''
select @sql = 'SELECT a.* FROM OPENROWSET('+@conn+','+@query+') AS a;'
exec( @sql )
select @ctr = @ctr + 1
end
go
In this script I want to replay trusted connection to user name & password.
as I'm new to query part please help me out.
Thanks in advance
Nitin
Thanks & Regards,
Nitin Gupta
SQl Server (7.0,2000,2005) - Sr. DBA
HCL Technologies, India
Post #817437
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.