Proper Procedure To Change Servername Of Replicated Environemnts?
Jul 22, 2005Hi There
View 4 RepliesHi There
View 4 RepliesHi all,
I've created 1 solution and added all my packages in different projects (like DIMENSIONS, SOURCES_SAP, ...).
For each project I have a Data Source that connects to the server. The problem is that when I want to deploy a package to the server that I always need to change the Data Source before deployment.
Before SQL Server 2005 we used a connection file (which was located as well on the server as on the development pc's in the same locations) within our DTS packages. This way we didn't had to change the connections when deploying to the server.
My intention was to use the current configuration from the configuration manager(development / production) to select the servername. Unfortunately, I didn't succeed to retrieve it's value from a variable script.
I need to have a solution that dynamically changes the datasources for multiple packages depending on a specific action.
How can I achieve this the easiest way ?
Thanks in advance !
Geert
I am launching a package the following way:
DTEXEC.EXE /SQL "ProcessReportingDatabase" /SERVER RTG23SQLDB01 /REPORTING V /SET "Package.Variables[User::RunID].Value";35 /SET "Package.Connections[RSAnalytics].Properties[InitialCatalog]";"Fnd Prj 1 Dec29" /SET "Package.Connections[RSAnalytics].Properties[ServerName]";"RTG23SQLDB01UAT1PROD"
The problem does not happen with the [User::RunID] variable or the [Initial Catalog] property of my [RSAnalytics] connection object. But I am not successful in setting the [ServerName] property.
What happens when executed is that the package retains the ServerName property of the deployed package (Value="RTG23SQLDB01UAT1QA"), instead of what I pass in via DTEXEC???
Is ServerName read-only or something? I've tried configuring the package connection to RTG23SQLDB01UAT1PROD and creating a package configuration that I specify in place of the /SET - but to no avail as well!
This package has to work against 10 instances. I really don't want to have to create a separate package for each instance, and then a hack to figure out which one to call.
TIA - Dave
Greets!
I have been told that simply stopping the SQL server service and backing up the data directory is all I have to do to do a backup of my data. Is this accurate?
Thanks,
Jimmy Ipock
I'm trying to handle a stored procedure parameter. What needs to happen is that a particular statement shouldn't be executed if the parameter is empty. However, when I try it I get the following error:Cannot use empty object or column names. Use a single space if necessary.So, what's the correct way of doing the following?IF @filename <> ""BEGIN UPDATE Experimental_Images SET contentType = @contentType, filename = @filename WHERE (id = @iconNo)END
View 1 Replies View RelatedHi..
I created a publication on my server and I just clicked the box to include all of the stored procedures. If I add a new procedure, will that procedure also be included? Or will I have to modify the publication for each SP I create?
Thanks!
-Greg
Hi
I have explicitly used
Exec SP_dropserver and
Exec SP_Addsserver SP's to drop and add a SQL server.
After that i restarted the sql server service. After that, when i used the query
select @@servername, it is returning NULL.
But, when I used Select Serverproprty('servername'), it is returning me the correct servername.
Can i know as why this behavior is exhibited for the same property of finding servername?
Thanks!
Rather than the real code, here's a sample we came up with.
Here's the C# Code:
public class sptest : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label1;
private DataSet dtsData;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
string strSP = "sp_testOutput";
SqlParameter[] Params = new SqlParameter[2];
Params[0] = new SqlParameter("@Input", "Pudding");
Params[1] = new SqlParameter("@Error_Text", "");
Params[1].Direction = ParameterDirection.Output;
try
{
this.dtsData = SqlHelper.ExecuteDataset(ConfigurationSettings.AppSettings["SIM_DSN"], CommandType.StoredProcedure, strSP, Params);
Label1.Text = Params[0].Value.ToString() + "--Returned Val is" + Params[1].Value.ToString();
}
//catch (System.Data.SqlClient.SqlException ex)
catch (Exception ex)
{
Label1.Text = ex.ToString();
}
}
Here is the stored procedure:
CREATE PROCEDURE [user1122500].[sp_testOutput](@Input nvarchar(76),@Error_Text nvarchar(10) OUTPUT)AS
SET @Error_Text = 'Test'GO
When I run this, it prints up the input variable, but not the output variable.
I have Transaction Replication setup on a Server X. Server X is publisher and distributor. Server Y is the Subscriber.Everything works perfectly. But I need to change the Database with a different DB on Server X that is being replicated to Server Y. I have following questions:
1- Do I create a new distributor on Server X and delete the current distributor?
2- Create a new Replication Setup on Server X and Y ?
3- Delete the subscriber DB on Server Y (Subscriber) ?
4- Can I just disable the current setup on Server X and Server Y instead of deleting it
Keep in mind this is my first compiled SQL program Stored Procedure(SP), copied from a book by Frasier Visual C++.NET in Visual Studio2005 (Chap12). So far, so theory, except for one bug (feature?)below. At some point I'm sure I'll be able to laugh about this, akinto forgeting a semi-colon in C/C++, but right now it's frustrating(time to sleep on it for a while).Problem--For some reason I get the error when trying to save files where twotables (called Author and Content), linked by a single key, form arelationship.By simple comparison of the source code in the textbook and my program(below) I found the difference: instead of, like in the textbook, theStored Procedure (SP) starting with "CREATE PROCEDURE", it*automatically* is (was somehow) given the name of 'ALTER PROCEDURE'and I cannot change this to "CREATE PROCEDURE" (you get an error in MSVisual Studio 2005 Pro edition of "There is already an object namedXXX in the database", see *|* below). No matter what I do, the SP isalways changed by Visual Studio 2005 to 'ALTER PROCEDURE'!!!(otherwise it simply will not save)Anybody else have this happen? (See below, others have had this happenover the years but it's not clear what the workaround is)Keep in mind this is my first attempt and I have ordered somespecialized books on SQL, but if this is a common problem (and Isuspect it's some sort of bug or quirk in VS2005), please let me know.Frankly I think SQL as done by VS2005 is messed up.Here are two Usenet threads on this problem:(1) http://tinyurl.com/2o956m or,http://groups.google.com/group/micr...1454182ae77d409(2) http://tinyurl.com/2ovybv or,http://groups.google.com/group/micr...9e5428bf0525889The second thread implies this is a bug--any fix?Also this bug might be relate to the fact I've switched (and notrebooted) from Administrator to PowerUser after successfully changingthe permissions in the SQL Server Management Studio Express (see thisthread: http://tinyurl.com/2o5yqa )Regarding this problem I might try again tommorrow to see if rebootinghelps.BTW, in the event I can't get this to work, what other SQL editor/compiler should I use besides MS Visual Studio 2005 for ADO.NET andSQL dB development?RL// source files// error message:'Authors' table saved successfully'Content' table- Unable to create relationship 'FK_Content_Authors'.The ALTER TABLE statement conflicted with the FOREIGN KEY constraint"FK_Content_Authors". The conflict occurred in database "DCV_DB",table "dbo.Authors", column 'AuthorID'.// due to the below no doubt!--CREATE PROCEDURE dbo.InsertAuthor /* THIS IS CORRECT (what I want)'CREATE PROCEDURE' not 'ALTER PROCEDURE'*/(@LastName NVARCHAR(32) = NULL,@FirstName NVARCHAR(32) = NULL)AS/* SET NOCOUNT ON */INSERT INTO Authors (LastName, FirstName)VALUES(@LastName, @FirstName)RETURN--ALTER PROCEDURE dbo.InsertAuthor /* WRONG! I want 'CREATE PROCEDURE'not 'ALTER PROCEDURE' but VS2005 won't save it as such!!!*/(@LastName NVARCHAR(32) = NULL,@FirstName NVARCHAR(32) = NULL)AS/* SET NOCOUNT ON */INSERT INTO Authors (LastName, FirstName)VALUES(@LastName, @FirstName)RETURN--*|* Error message given: when trying to save CREATE PROCEDURE StoredProcedure: "There is already an object named 'InsertAuthor' in the dB
View 11 Replies View RelatedFolks !!
Select @@Servername results in 'NULL' !
For some reason, i can't get the name of the server !!1
Any Thoughts
Girish
I am getting a null value when i am query the Global variable @@servername.
Please help !!
Thanks
vIVEk.
hi!i can't find out the name of the sql2000-server witch is running not local.i know the username,password and i hear that "System-stored Procedure
" are the right one's. but i don't know how i do this. anyone else? thx robert
If anybody can explain why for one of my SQL Server2000 servers the statement select @@servername returns NULL instead of name?
Thanks
I recall a method to get the old servername of a SQL server but old age has gotten to me.
I suspect a particular server has been renamed at one point. Obviously it wasn't me and the person before me is not around for me to ask.
So, can someone help an old guy out?
The results of print @@servername is NULL.
Thanks
I work at a medical billing office. We provide billing services for a number of clients. The primary billing software runs on a big AIX system, but for reporting and a few other things we get a daily dump into sql server. The way the dump happens each client get's their own database in sql server. This works great for reports that go to individual clients, but it can be a real pain for internal reports that cover all clients. We end up with sql code that looks something like this:
SQL Code:
Original
- SQL Code
ALTER PROCEDURE ProceName
AS
BEGIN
CREATE TABLE #Temp
(
Client varchar(5),
FieldName varchar(20),
OtherField int
)
DECLARE @Client varchar(5)
DECLARE @SQL varchar(8000)
DECLARE curAll cursor FOR /*SQL Code to get Client list here */
OPEN curAll
FETCH NEXT FROM curAll INTO @Client
WHILE @@FETCH_STATUS = 0
BEGIN
Set @SQL =
'SELECT ''' + @Client + ''', *'
+ ' FROM dump_' + @Client + '.dbo.TableName t'
+ ' WHERE t.FieldName=''somevalue'''
INSERT INTO #Temp
Exec(@SQL)
FETCH NEXT FROM curAll INTO @Client
END
--send results to application
SELECT * FROM #Temp
--clean up
CLOSE curAll
DEALLOCATE curAll
DROP Table #Temp
END
ALTER PROCEDURE ProceNameASBEGIN CREATE TABLE #Temp ( Client varchar(5), FieldName varchar(20), OtherField int ) DECLARE @Client varchar(5) DECLARE @SQL varchar(8000) DECLARE curAll CURSOR FOR /*SQL Code to get Client list here */ OPEN curAll FETCH NEXT FROM curAll INTO @Client WHILE @@FETCH_STATUS = 0 BEGIN SET @SQL = 'SELECT ''' + @Client + ''', *' + ' FROM dump_' + @Client + '.dbo.TableName t' + ' WHERE t.FieldName=''somevalue''' INSERT INTO #Temp Exec(@SQL) FETCH NEXT FROM curAll INTO @Client END --send results to application SELECT * FROM #Temp --clean up CLOSE curAll DEALLOCATE curAll DROP TABLE #TempEND
As you can imagine, this is a real pain. There must be someway to dynamically change the current database in the procedure and run the code there directly rather than creating a string and calling out to exec 50+ times. Any ideas?
Hi,
I have a schedule task which call one of my stored procedure,
In this stored procedure, I need to change db owner of one of
database, but I find sp_changedbowner do not allow me to specify
db name,it only change current db,so I have to open a db before
call sp_changedbowner,but it is invalid..
CREATE PROC demo
as
begin
...
use demo_db //it is invalid
exec sp_changedbowner 'scott'
end
Can anyone give me ideas?
Thanks
Hello. I am trying to change the owner of a stored procedure from a user ID to dbo. How do i do this. I have tried sp_changeobjectowner but I get an error message. Can I do this from Enterprise Manager? btw, I am using SQL 7.0. Any help would be appreciated. Thanx
View 2 Replies View RelatedCan someone explain to me why the following doesn't work?declare @oname sysnameselect @oname=name from sysobjects where name like"df__mytable__mycol%"alter table mytable drop constraint @oname
View 4 Replies View RelatedHey folks,
Today's been way too much fun...
Someone changed the name of a machine in our department and now Win2k thinks the machine's name is (for example) "Fred", but if I do a select @@servername, SQL returns (again, for example) "Barney".
The machine's name started out as "Barney".
The last time this happened, it was on an NT4 box, and we just reinstalled sql and away we went.
This time, they reinstalled sql and released the box to the team, only to find out later that reinstalling sql didn't do squat this time.
Which brings me to the question: How do I convince SQL that it's really, truly supposed to be named "Fred"?
Besides that, what do I tell Wilma, Betty, Pebbles and Bamm Bamm?
Any assistance would be greatly appreciated.
: )
Thanks,
Tom
I want create replication through Create Publication Wizard . But I have
got error , that variable @@SERVERNAME is NULL!!!!!But I have my server
with NF5500 name! I query SELECT @@SERVERNAME. But I get NULL. I tried to use
SP_ADDSERVERNAME procedure to add server name, but I have got message that server with this name already exist. Please help me!!
Thanx in advance!!
Hello sir,
I have a probleme with a replication.
I have two servers (serv1 and serv2); when i want to install a replication from serv1 to serv2, i receive this message:
1->2:Replication cannot be installed as @@SERVERNAME is NULL.
from serv2 to serv1; I receive this message:
2->1:If Replication is uninstalled, all publications will be
eliminated and the distribution database[if it exist]will be
dropped. After the process has completed, this session will be
disconnected from the SQL Server. Do you want to unistall
replication?
Please advice me..
On one of my SQL Servers I have noticed the @@servername to be NULL.
Any Idea how to give it back the original value. Simple
>> SELECT @@servername = `MY_SERVER_NAME` will not work since I can not update the global variable
This prevents from instaling publishing on that server, among other concerns for the overall stability of the server.
Help appreciated,
Bojan
Hi :
Can anyone tell me if it is possible to get information like : servername/databasename inside an extended stored procedure ?
I checked the "srv_pfield" function but it only returns user/password information.
Thanks,
Rui
Someone renamed a server from 2A to A.When I do @@servername I get 2A.The server/machine name is 2.Should my triggers say 2A or 2? Does it matter?Thanks
View 3 Replies View Related
Please help:
when I want to create new data source from Data > Add New Data Source > Database > New Connection > Choose data sourse: MS Sql Server > Continue > Server name ----------> here in server name field i can see a lot of server names but not mine... so I'd like you to help me to find my server name...
thanks in advance!
I am using a web application using asp.net 1.1 vs 2003.
i am using sql server authentication where users are using their sql server user id and sql server saved passwords.
how can i change their passwords inside the sql server?
is there a system sp that allows one to pass one's user id and then change password.
I will need to call that sp from a user defined store dprocedure and pass the parameters and that will change the password on the sql server.
thanks
I need help on how to change the date format in a stored procedure. I am using the GetDate() function but need to convert it to short date format.
thanks
mike
Hi All,
My scenario is that I want to change the default SQL server format in my stored procedure more preferably only during the course of stored procedure execution (not permanent changes does any one have idea that how will I able to achieve this simple task...
regards,
Anas
help
i need to create stored procedures that run once month
change value (UPDATE) once a month in one table the values from 1,2,3,4 next month 2,3,4,1 ..... 3,4,2,1 .......4,1,2,3 ..... 1,2,3,4
i have this code
Code Snippet
SELECT empID, location, ISNULL(NULLIF (( location + DATEDIFF(mm, location_date, GETDATE())) % 4, 0), 4) AS new_location
FROM dbo.empList
like this the employee go from one location once amonth to new location
table on this month (5)
empid location location_date
--------------------------------------------------------------
1111 1
222 2
333 3
444 4
5555 3
666 2
777 3
888 4
table on next month (6) (after a month)
empid location location_date
-------------------------------------------------------------------
1111 2
222 3
333 4
444 1
5555 4
666 3
777 4
888 1
TNX
I am trying to script out the creation of database scripts. I am tryingto use @@servername in the statement. I found out the select@@servername returns NULL. I used sp_dropserver to drop any servernamesfirst, restarted SQL, ran sp_addserver 'servername' to add theservername, restarted SQL. select @@servername still returns NULL...Any ideas why this may be happening?Thanks,TGru*** Sent via Developersdex http://www.developersdex.com ***Don't just participate in USENET...get rewarded for it!
View 2 Replies View RelatedI would like to parameterize the server name and database name in a query inside a stored procedure. I would like to avoid using the exec(@SqlCmd) technique if possible. HELP?
View 4 Replies View RelatedI'm using SQL Manager from my Enterprise server to connect to my SQL Express server that will act as a witness to a db mirroring system. If I try to connect to the SQL Express server using its IP address, I get a "named pipes error 53." If I connect by browsing the network and connect to the Name of the Server "MachinenameSQLExpress", I am successful. I would like to be able to connect to the IP directly as it's not dependant upon certain services to be started or configured a certain way.
Thank you,
Chad