Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
jandh98
Starting Member
10 Posts |
Posted - 2015-01-29 : 15:35:42
|
I'm trying to create a view that gets the sql server from another table. So I'd like to create something like:Create View as SelectnamefromTHISSERVER.system.dbo.employeeTHISSERVER can change - and I can create dynamic sql that will execute but it will always put THISSERVER. What I want is to not have that hard coded in the view.Hopefully that makes sense. |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2015-01-29 : 15:39:55
|
You can't do that with a view as dynamic sql is not allowed in there. You could use a stored procedure, but I question this design. Why are you using the four-part name for the object if the object is local?Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
viggneshwar
Yak Posting Veteran
86 Posts |
Posted - 2015-01-30 : 10:19:22
|
Four part is required right SERVERNAME.DATABASENAME.SCHEMANAME.TABLENAME.He is trying to do the dynamic part. So that even that is local server he has to specify the servername.RegardsViggneshwar A |
|
|
|
|
|