Showing posts with label instead. Show all posts
Showing posts with label instead. Show all posts

Monday, March 26, 2012

Rename tables and fields

I want to rename all tables and fields that starts with 'AAA_' to start with
'BBB_' instead. How can I do that?Check out "sp_rename" in the SQL Server books online.
--
HTH,
SriSamp
Email: srisamp@.gmail.com
Blog: http://blogs.sqlxml.org/srinivassampath
URL: http://www32.brinkster.com/srisamp
"aEva" <aEva@.discussions.microsoft.com> wrote in message
news:35B7A3F3-459B-4B5E-8471-48668716D26B@.microsoft.com...
> I want to rename all tables and fields that starts with 'AAA_' to start
> with
> 'BBB_' instead. How can I do that?|||examnotes (aEva@.discussions.microsoft.com) writes:
> I want to rename all tables and fields that starts with 'AAA_' to start
> with 'BBB_' instead. How can I do that?
SELECT 'EXEC sp_rename ''' + name + ''', ''BBB_' +
substring(name, 4, len(name)) + ''''
FROM sysobjects
WHERE type = 'U'
AND name like 'AAA[_]%'
SELECT 'EXEC sp_rename ''' + o.name + '.' + c.name + ''', ''BBB_' +
substring(c.name, 4, len(c.name)) + '', ''column'''
FROM syobejcts o
JOIN syscolumns c ON o.id = c.id
WHERE c.name LIKE 'AAA[_]%'
AND o.type = 'U'
Cut and past result into query window and run.
Untested, so you may have weed out some syntax errors.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.aspsql

Rename Membername in a "server time dimension" - Calendar 2007 -> 2007

Hi.

Possibly a simple question...

I generated a server time dimension and want overwrite the shown text. Instead of e.g. Calendar 2007 I want only show 2007. But I do not find a way to overwrite the member labels.

THX for any help,

Nils

Hi,

Create a named calculation with the name "CALYEAR" and in Expression

Substring(fieldname,10,4)

Note: fieldname is your column name

It will create a new named calculation with the name "CALYEAR"

Open the Server time Dimension and click on the field Calenderyear and select the Properties.

In properties Select NameColumn and Select the Source and change the ColumnID -> CALYEAR.

Deploy it and check it out

This will help you

Dinesh

Tuesday, March 20, 2012

rename a DB

By mistake I name a db something.com instead of something_com.
so now it won't let me do some design things. it already has data in it and
the export routine Urps because of the naming so I can not copy it over to
something_com.
is there a way to rename the sysdatabase to something_com?try...
use master
go
exec sp_renamedb 'something.com','something_com'
go
-oj
RAC v2.2 & QALite!
http://www.rac4sql.net
"BJ Freeman" <bj_newsgroups@.free-man.net> wrote in message
news:%239xLXjjiDHA.2536@.TK2MSFTNGP10.phx.gbl...
> By mistake I name a db something.com instead of something_com.
> so now it won't let me do some design things. it already has data in it
and
> the export routine Urps because of the naming so I can not copy it over to
> something_com.
> is there a way to rename the sysdatabase to something_com?
>|||thanks. the only thing I had to-do, extra, was set the DB to single user.
could have used dboptions, but used the enterprise manager.
"oj" <nospam_ojngo@.home.com> wrote in message
news:uQmc9njiDHA.1456@.TK2MSFTNGP11.phx.gbl...
> try...
> use master
> go
> exec sp_renamedb 'something.com','something_com'
> go
>
> --
> -oj
> RAC v2.2 & QALite!
> http://www.rac4sql.net
>
> "BJ Freeman" <bj_newsgroups@.free-man.net> wrote in message
> news:%239xLXjjiDHA.2536@.TK2MSFTNGP10.phx.gbl...
> > By mistake I name a db something.com instead of something_com.
> > so now it won't let me do some design things. it already has data in it
> and
> > the export routine Urps because of the naming so I can not copy it over
to
> > something_com.
> > is there a way to rename the sysdatabase to something_com?
> >
> >
>|||then do...
use master
go
alter database [something.com] set single_user with rollback immediate
go
exec sp_renamedb 'something.com','something_com'
go
alter database [something_com] set multi_user with rollback immediate
go
--
-oj
RAC v2.2 & QALite!
http://www.rac4sql.net
"BJ Freeman" <bj_newsgroups@.free-man.net> wrote in message
news:e7QmyHoiDHA.1692@.TK2MSFTNGP10.phx.gbl...
> thanks. the only thing I had to-do, extra, was set the DB to single user.
> could have used dboptions, but used the enterprise manager.
>
> "oj" <nospam_ojngo@.home.com> wrote in message
> news:uQmc9njiDHA.1456@.TK2MSFTNGP11.phx.gbl...
> > try...
> >
> > use master
> > go
> > exec sp_renamedb 'something.com','something_com'
> > go
> >
> >
> > --
> > -oj
> > RAC v2.2 & QALite!
> > http://www.rac4sql.net
> >
> >
> >
> > "BJ Freeman" <bj_newsgroups@.free-man.net> wrote in message
> > news:%239xLXjjiDHA.2536@.TK2MSFTNGP10.phx.gbl...
> > > By mistake I name a db something.com instead of something_com.
> > > so now it won't let me do some design things. it already has data in
it
> > and
> > > the export routine Urps because of the naming so I can not copy it
over
> to
> > > something_com.
> > > is there a way to rename the sysdatabase to something_com?
> > >
> > >
> >
> >
>|||An alternative method to oj's suggestion with SQL 2000 is ALTER DATABASE
... MODIFY NAME. This eliminates the separate steps to place the
database in single-user mode. However, exclusive database access is
still required. For example:
ALTER DATABASE MyDatabase
MODIFY NAME = MyNewDatabaseName
--
Hope this helps.
Dan Guzman
SQL Server MVP
--
SQL FAQ links (courtesy Neil Pike):
http://www.ntfaq.com/Articles/Index.cfm?DepartmentID=800
http://www.sqlserverfaq.com
http://www.mssqlserver.com/faq
--
"BJ Freeman" <bj_newsgroups@.free-man.net> wrote in message
news:e7QmyHoiDHA.1692@.TK2MSFTNGP10.phx.gbl...
> thanks. the only thing I had to-do, extra, was set the DB to single
user.
> could have used dboptions, but used the enterprise manager.
>
> "oj" <nospam_ojngo@.home.com> wrote in message
> news:uQmc9njiDHA.1456@.TK2MSFTNGP11.phx.gbl...
> > try...
> >
> > use master
> > go
> > exec sp_renamedb 'something.com','something_com'
> > go
> >
> >
> > --
> > -oj
> > RAC v2.2 & QALite!
> > http://www.rac4sql.net
> >
> >
> >
> > "BJ Freeman" <bj_newsgroups@.free-man.net> wrote in message
> > news:%239xLXjjiDHA.2536@.TK2MSFTNGP10.phx.gbl...
> > > By mistake I name a db something.com instead of something_com.
> > > so now it won't let me do some design things. it already has data
in it
> > and
> > > the export routine Urps because of the naming so I can not copy it
over
> to
> > > something_com.
> > > is there a way to rename the sysdatabase to something_com?
> > >
> > >
> >
> >
>