x
login about faq Site discussion (meta-askssc)

OpendataSource

(select @@servername from OPENDATASOURCE('SQLNCLI', 'Data Source=Servername ;Integrated Security=SSPI') .DBNAME.dbo.BSC )

For the above query i need to parameterised the 'Data Source=Servername .

How it can be done .

more ▼

asked May 17 '12 at 07:19 AM in Default

jhunu gravatar image

jhunu
90 12 25 29

@Jhunu Just in case you missed it, for the whole month of May, accepting an answer will add 50 points to the profile. Your profile shows that if you start accepting answers to your questions, you can certainly get more than 500 points :)

May 17 '12 at 09:22 AM robbin
(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

You can use dynamic sql for that

DECLARE @ServerName NVARCHAR(500)

SET @ServerName = N'ServerName'

EXEC ('select TOP 1 @@servername from OPENDATASOURCE(''SQLNCLI'', ''Data Source='+ @ServerName + ' ;Integrated Security=SSPI'').master.dbo.spt_values')
more ▼

answered May 17 '12 at 09:07 AM

robbin gravatar image

robbin
1.6k 1 3 5

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments



Facebook logo Follow Ask SSC on Facebook
Find Ask SSC on Google+
linkedin logo Find us on LinkedIn

Topics:

x92
x1

asked: May 17 '12 at 07:19 AM

Seen: 728 times

Last Updated: May 17 '12 at 09:22 AM

Copyright © 2002-2012 Simple Talk Publishing. All Rights Reserved. If you have any queries, please contact the site administrators.
Ask SQL Server Central is a community service provided by Red Gate.