Renaming A Column Name On Multile Databases
Mar 3, 2008Hi there,
Can anyone tell me how to run sp_rename to rename a column name on multile databases? I have 150 databases to update.
thanks very much
Hi there,
Can anyone tell me how to run sp_rename to rename a column name on multile databases? I have 150 databases to update.
thanks very much
Hi,
I want to implement the following pattern (pseudo-code follows):
[for index in x different databases, where x is rather big]
create database MyDatabase_#{index}_Temp
launch a dedicated ssis package on this database
if I detect no error, proudly rename MyDatabase_#{index}_Temp to MyDatabase_#{index}_Last_Known_Good (drop the last_known_good first if it exist)
Later on, a consolidation process collect the data in Last_Known_Good versions of the databases.
My question: what is the simpliest way to achieve the rename operation (step 3) ?
I have tried an "alter database #{old_database_name} modify name = #{new_database_name}", but it works only once: once renamed, the database keeps the old mdf and ldf filenames, and the next create database will choke on this.
I have also tried to rename the logical filenames with ALTER DATABASE XXX MODIFY FILE (NAME = YYY, NEWNAME = ZZZ) but it doesn't work either.
I'd like to avoid specifying absolute mdf and ldf filenames myself, is it possible ?
best,
Thibaut
ALTER TABLE ISMPBI CHANGE `PBICCGRFNUM` `PBICCGRFNUM1` BIGINT NOT NULL;
this query to rename column name in my sql but not working in sql server
so what is exact syntax to rename column
hello friends!
1 silly dought again..
I hav a table with 4 columns and it has 5 rows..
Now i want to change the name of 1 of the column
Is there any query to rename an existing column??
THANK YOU!
I got a table which gets populated by stor proc where we pivot the Sum(Balance of mortgage) by YYYYMM for the whole duration of the loan term.
I have a requirement to rename the column header where the previous month end balance period be renamed to P0.
if we run the report today, then the balance as at 31/09 should show under column P0 which now shows under 201509 and then P0 keeps shifting with each month run.
How do I dynamically rename the column headers.
i have the folowing databases DB1,DB2,DB3,D4,DB5........
i have to loop through each of the databases and find out if the database has a table with the name 'Documents'( like 'tbdocuments' or 'tbemplyeedocuments' and so on......)
If the tablename having the word 'Documents' is found in that database i have to add a column named 'IsValid varchar(100)' against that table in that database and there can be more than 1 'Documents' table in a database.
can someone show me the script to do it?
Thanks.
I am familiar with the sp_MSForEachDBand the USE Parameter I did Google and found [URL]
View 3 Replies View Related
I have Two Database that exist on Two seperate servers. The two database contain same schema and contains tables and columns of same name. Some tables have slight differences in terms of data types or Data type lenght.
For example if a Table on ServerA has a column named - CustomerSale with Varchar (100, Null) and a table on ServerB has a column named CustomerSale with Varchar (60, Null), how can i find if other columns have similar differences in all tables with the same name and columns in the two servers.
I am using SQL Server 2005. And the Two Servers are Linked Servers
What Script can i use to accomplish this task. Thanks
Hello all:
I need to rename my 2000 Server running an instance of SQL 2000. My question is this, will I have to reinstall SQL after the rename or will it come back up detecting the new server name. I am in a domain as a stand alone server.
Thanks.
I searched, but couldn't find anything to match what I am looking for...
Basically, is there any way to tell DTS to create a new table each time that the backup is run? I am scheduling the backup for 1 hour intervals for 5 days, but need the databases that are backed up to be unique, so i would end up wiht 120 of them total.
Is there any way to do this through DTS? Or am I hosed?
Thanks in advance
Is it possible to rename a DTS package ??
View 1 Replies View Relatedhi,
I had a table and it has certain dependecies(like stored proc.).
I rename the table and created anew one with same name.this new table did not inherited all the dependecies which it should.
To say,
I had a table TAB.I renamed it to TAB_old and made a new table with name TAB.When I go to SEM and click on 'Display Dependencies' table TAB is not showing anything whereas TAB_old is stil showing all the dependecies.I even ran Update stats and sp_updatestats.
any idea what is this going on.....
TIA
hi
how to rename sql server in 7.0 without reinstalling or renaming the computer name? Any help will be appriciated?
regards
ganesh
How do you rename a SQL server?
View 2 Replies View RelatedAfter I renamed the server. Jobs that exsisted before I renamed the server are still associated with the original server name. It has associated those jobs with the original server and assumes that the original server is the MSX server. I do not have multiple instances running on the server and do not want it that way. Is there a way to change the originating server? Or remove the MSX server?
HELP!
We need to rename our server.
Example
SERVER_A renamed to SERVER_B and
SERVER_B renamed to SERVER_A
It is easy enough to change the NT box name. Other than using sp_DropServer and sp_AddServer, is there any other changes (updates) we need to make to SQL server or any system tables???
TIA,
Chris
Hi All...
Does any one know a utility / script that could be used to connect to remote SQL server DB and rename/delete some tables... DOn't have Enterprise Manager right now and need this urgently .....
Thanks all
How do you rename files (database logical file names) in SQL2000???
Suppose I have the following :
logical file name filepath
myDB i:myDB.mdf
myDB_log i:myDB_log.ldf
HOW DO I RESTORED THE ABOVE TO SAME SERVER BUT AS FOLLOWS:
logical file name filepath
myDB_QA i:myDB_QA.mdf
myDB_QA_log i:myDB_QA.ldf
PLEASE ADVISE OF ANY SOLUTION (so I do not receive logical filename errors).
Thanks very much
Ziggy
Can anyone suggest a quick and easy way to rename a database AND .MDF/.LDF file in SQL Server?
I can not, for the life of me, figure out a way to do this.
Help?
I am using SQL Server Management Studio with SQL Server 2005. On my development SQL server, I have developers using a database named TestData. An off-site developer has sent new versions of TestData.MDF and TestData.LDF. I want to attach this new database to the same development server for testing, without overwriting the existing database in use by the developers. How can I rename this new TestData to something like TestDataNew while attaching it? I only have the MDF and LDF files.
Thanks.
Hi all,
I need to rename the Columns of a table in SQL Server 2005.
The table is consisting of nearly 200 columns and the requirement is that every column needs to be appended with a name that would be given by me.
Example:
Let the name of the table be "Applicationdata"
let it contain columns say
Name
DOB
Gender
Place
Qualification
now I need to add a code say "Appl" before every column so that after the code is run, the column names sholud be changed as
Appl_Name
Appl_DOB
Appl_Gender
Appl_Place
Appl_Qualification.
Do we have any procedure like that, if yes, please post it.
I have had a go at using a package with a script to rename and move a file and it works well by using a script task in a package with source and destination variables. See script at bottom
But in my scenario the file thst comes in every day will have a slightly different name. It will be called "System_UT_INCR_BOOKINGHEADER_20080228000000.TXT"
On the 28th Feb. The date part of the title changes everyday.
SO i need to adjust my "Source" variable which is currently just a string with a value of "C:DatafilesimportsSystem_UT_INCR_BOOKINGHEADER_20080228000000.TXT" So it will only ever look for that exact file name
Imports System.IO
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Public Class ScriptMain
' The execution engine calls this method when the task executes.
' To access the object model, use the Dts object. Connections, variables, events,
' and logging features are available as static members of the Dts class.
' Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.
'
' To open Code and Text Editor Help, press F1.
' To open Object Browser, press Ctrl+Alt+J.
Public Sub Main()
Try
File.Move(Dts.Variables("Source").Value.ToString, Dts.Variables("Destination").Value.ToString)
Dts.Events.FireInformation(0, "", "File Moved Succesfully", "", 0, True)
Catch ex As Exception
Dts.Events.FireError(1, "", "Source file or destinations does not exist", "", 0)
End Try
Dts.TaskResult = Dts.Results.Success
End Sub
End Class
HelloI am wondering if this is able to be done and what implications there wouldbe with SQL Server.Server1 name: Production Currently running Windows NT and SQL 7instance name is ProductionServer2 name: Test Currently running Windows 2000 andSQL 2000, instance name is Test - default installationBring the Server1 offline and rename Server 2 with the name of Production.Do we have to change the instance name in SQL now on Server 2? If so can wedo this? I didn't think you could change a instance name and had toreinstall SQL.Another Question:Can you have 2 instances of SQL with the same name but reside on differentservers?ThanksSher
View 2 Replies View RelatedThe previous post regarding dependencies reminded me of another bugger I comeup with from time to time. SQL Server allows us to rename objects via asystem stored procedure (I usually use an ADP front-end that presumably callsthe same procedure), but after the rename, I find singnificant strangeness.For instance, triggers are still connected to the tables, but the trigger textstill refers to the old table name. Views and stored procedures dependent onthe table are broken, and are not fixed by even by restarting the server,though I thought the cached plans were supposed to be dumped on shut-down,then recreated on demand later.Is there some tool or technique to rename a table and automatically detect andproperly drop/rebuild dependent triggers, views, stored procedures,relationships, and anything else I'm not thinking of?Oh yeah, and there are extended properties to deal with as well, but I guessthat's intractible unless we know what client build them (e.g. Access ADP),and what it expects to be recorded there, but I suppose it would be nice tojust dump them rather than leave them there possibly corrupted from a client'spersective.
View 4 Replies View RelatedHi all,
I have a Windows 2003 server box running SQL 2000 and BizTalk 2006. I need to change the name of the underlying server, could anyone point me in the right direction of what I would need to change in terms of SQL and BizTalk config to make it all sit happily with this?
Kind regards
Taz
I used the wizard to create a package that loads data from Access into SQL Server 2005. I then saved the package to the File System and added to my project.
I had two connections, one for SQL and one for Access. When I rename either one, the source or destination tasks in the Data Flow task reset to the other connection and/or I get an error that the old connection ID cannot be found.
I solved by opening the dtsx in Notepad and doing a global find/replace for the connection ID's. This is a real hassle.
Hi! I'm trying to rename tables in a msde database, without succeeding. Simple question, I guess, but I can't find out how to do this. I know this doesn't work though:--- Dim connectionString As String = "server='(local)'; trusted_connection=true; database='GustafTest1'"Dim cn As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionString)Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand
cn.Open()
Dim queryString As String = "RENAME TABLE table1 TO table2" '"ALTER TABLE [table1] RENAME TO [table2]"
dbCommand.CommandText = queryString dbCommand.Connection = cndbCommand.ExecuteNonQuery()---The reason to why I want to do this is that I'm updating the information of my system, and store the new data in a temporary table during update, in case something goes wrong. If the storing goes alright, the newly loaded the old table is renamed to backup_table and the temporary table is renamed from updating_table to active_table.That is a good solution, right?Thanx,Jon Engström, Sweden
Do I have to re-install SQL2000 if I change the Win2000 Server name.
Thanks
Hello,
I have a situation where I'm coding a database upgrade utility for my current project in Java. I have to rename the current version of each table to tablename_orig and then create the new version of the table from a text file which contains a create table statement. Once the new table is created, I compare the table definitions and do a bunch of other stuff. The problem is that I don't seem to be able to find a way to rename the table through SQL. I know that in Oracle I can use a Create Synonym statement, but how can I rename tables for SQL Server? Any help would be greatly appreciated!
Scott Cole
Conceptual Systems Inc.
State College, PA
I'm moving a database (XYZtest) from the test server to the production server via sp_detach/sp_attach. I want the logical file names to be XYZ_data, rather than XYZtest_data, etc. I can easily rename the disk files, but how do I rename the logical file names?
Thanks,
Al
I want to be able to rename a file in a specific folder using TSQL or a stored procedure.
More generically, I want to be able to perform file operations (i.e. renaming, copying, deleting etc.) at the OS level using TSQL.
Is there a stored procedure or other command in TSQL that facilitates this?
Hi,
My original account on the AD (Active Directory) was Usr129 and at that time I had installed MSDE on my local box - due to which my "local MSSQLServer" was also called Usr129.
Sometime back our LAN administrator renamed the accounts of all users. My new account on the AD (after this renaming) became GBUsr1177. Untill recently, my "local MSSQLServer" also appeared to have easily go through this renaming activity and thus my local installation became GBUsr1177.
Recently I started to have performance problem (on everything that I do on my local SQL installation via Enterprise manager) and I have this "feeling" that probably at the bacground it is still searching for the old SQL installation???
Can someone please guide me regarding how to get out of this (without re-installating everything).
I am experiencing a big problem with my prod server.I renamed my production server as my test sever (abc) and the test server to (xyz) in sql 2000.
Now, when I connect from my test server to my prod server, it does not seem to see the new server even I put the new server name. It still sees the databases what is in the test server, not the new server databases.
How can I resolve this?
Please help. Thank you all.