x

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, 2012 at 07:19 AM in Default

avatar image

jhunu
110 29 30 36

@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, 2012 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, 2012 at 09:07 AM

avatar image

robbin
1.7k 1 5 10

(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

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x134
x2

asked: May 17, 2012 at 07:19 AM

Seen: 2110 times

Last Updated: May 17, 2012 at 09:22 AM

Copyright 2016 Redgate Software. Privacy Policy