Showing posts with label analyzer. Show all posts
Showing posts with label analyzer. Show all posts

Thursday, March 29, 2012

Deleting stored procedures through query analyzer

Hi All!

I know this must be a very silly question but, what is the PLSQL string I have to use to delete a stored procedure in a database? Essentially I have to remove a stored procedure that comes from a database backup every night because it belongs to a user and that user has to be recreated in the new SQL Server 2000. Simply put:

1. Production database comes into test database
2. Remove copy of stored procedure since it can not be set to dbo user because there is another copy with the same name that belongs to dbo.
3. Remove user
4. Add user (this one brings login name since the restored one didn't)
5. Have a nice day

I've got everything except removing the stored procedure so I will really appreciate the help.

Thank you all!

Rijckewaert wrote:

Hi All!

I know this must be a very silly question but, what is the PLSQL string I have to use to delete a stored procedure in a database?

Transact-SQL ... here Oracle is notwelcome

the actual traditional code is

IF OBJECT_ID('[schema/owner].[object]') IS NOT NULL

DROP PROCEDURE [schema/owner].[object];

Essentially I have to remove a stored procedure that comes from a database backup every night because it belongs to a user and that user has to be recreated in the new SQL Server 2000. Simply put:

1. Production database comes into test database
2. Remove copy of stored procedure since it can not be set to dbo user because there is another copy with the same name that belongs to dbo.
3. Remove user
4. Add user (this one brings login name since the restored one didn't)
5. Have a nice day

I've got everything except removing the stored procedure so I will really appreciate the help.

Thank you all!

this "design" is not clear to me... why would you always drop an object to be recreated (if the inner code remains the same)?

is this becouse of the well known "orphaned users" problem?
this problem (perhaps the problem you are experimenting) is involved when a "restored" database user(s) is no longer mapped to a corresponding server's standard SQL Server login..
in SQL Server 2000 this means the relationship between master.dbo.syslogins is broken with database.dbo.sysusers...
actually the JOIN on master.dbo.syslogins.sid ~ database.dbo.sysusers.sid

if this is the case, you do not need to delete the object and the user... you just need to resync it/them, via the sp_change_users_logins system stored procedure http://msdn2.microsoft.com/en-us/library/ms174378.aspx ... please have a look at http://msdn2.microsoft.com/en-us/library/ms175475.aspx as well..

if this is not the case... please expand

regards

Tuesday, March 27, 2012

Deleting old servers still listed in Query Analyzer ????????

I can use the Client Network Utility (CNU) from SQL 2000 to create/delete
aliases.
But when I 1st run Query Analyzer (QA)... it shows a list of some old
servers we used to have... long ago.
How do I delete from that list?
(The old servers have already been removed from the CNU alias list... but
they seem to stay listed in QA forever.)
They have nothing to do with each other. Any registrations you did in QA or
EM you will have to manually delete them from the registrations by right
clicking and choosing Delete.
Andrew J. Kelly SQL MVP
""A_Michigan_User"" <Michigan_RE_M0VE@.ameritech.net> wrote in message
news:%23gKQ7lwOGHA.3944@.tk2msftngp13.phx.gbl...
>I can use the Client Network Utility (CNU) from SQL 2000 to create/delete
>aliases.
> But when I 1st run Query Analyzer (QA)... it shows a list of some old
> servers we used to have... long ago.
> How do I delete from that list?
> (The old servers have already been removed from the CNU alias list... but
> they seem to stay listed in QA forever.)
>
>
|||"A_Michigan_User" wrote:
> I can use the Client Network Utility (CNU) from SQL 2000 to
> create/delete aliases.
> But when I 1st run Query Analyzer (QA)... it shows a list of some old
> servers we used to have... long ago.
> How do I delete from that list?
> (The old servers have already been removed from the CNU alias list...
> but they seem to stay listed in QA forever.)
For QA, the servers are stored here in the registration database:
HKEY_CURRENT_USER\Software\Microsoft\Microsoft SQL
Server\80\Tools\Client\PrefServers
You can remove the pairs you do not need - carefully. I don't know how
to remove servers from the QA drop-down list in the connection dialog
other than by editing the regdb. I see different servers listed in QA
than I have for SQLEM, so removing the server from SQLEM does seem like
it will work in QA.
David Gugick - SQL Server MVP
Quest Software
|||> They have nothing to do with each other.
I thought I *HAD TO* add them with CNU... then they appeared as "available"
in QA and EM.
No?
"Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
news:eP%237NMyOGHA.1312@.TK2MSFTNGP09.phx.gbl...[vbcol=seagreen]
> They have nothing to do with each other. Any registrations you did in QA
> or EM you will have to manually delete them from the registrations by
> right clicking and choosing Delete.
> --
> Andrew J. Kelly SQL MVP
>
> ""A_Michigan_User"" <Michigan_RE_M0VE@.ameritech.net> wrote in message
> news:%23gKQ7lwOGHA.3944@.tk2msftngp13.phx.gbl...
|||The CNU just allowed you to alias them. Then maybe you can see them thru
the alias but that is not a requirement to register a server. You just need
the name or IP address of the server and it has to be available on the right
port, 1433 by default.
Andrew J. Kelly SQL MVP
""A_Michigan_User"" <Michigan_RE_M0VE@.ameritech.net> wrote in message
news:eqFg7jlRGHA.2156@.tk2msftngp13.phx.gbl...
> I thought I *HAD TO* add them with CNU... then they appeared as
> "available" in QA and EM.
> No?
>
> "Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
> news:eP%237NMyOGHA.1312@.TK2MSFTNGP09.phx.gbl...
>

Sunday, March 25, 2012

Deleting Indexes

Is there a way to delete the indexes on all the tables for a specific
database in SQL Server using Query Analyzer without knowing the exact name o
f
the Index? I am able to do this using SQLDMO, but I need to know if there is
a way to do this using Query Analyzer.
ThanksYou might want to look at the sysindexes table
Select * from sysindexes
I would create a cursor to loop through the sysindexes table and issue the
command
Drop Index TableName.IndexName
Both TableName and IndexName can be found in Sysindexes table
HTH
Ed
"JD" wrote:

> Is there a way to delete the indexes on all the tables for a specific
> database in SQL Server using Query Analyzer without knowing the exact name
of
> the Index? I am able to do this using SQLDMO, but I need to know if there
is
> a way to do this using Query Analyzer.
> Thanks|||This will not take care of indexes implicitly created by, say PK and Unique
constraints, but it may be a start:
select 'DROP INDEX '+object_name(id)+'.'+object_name(object_id(name))
from sysindexes
WHERE objectproperty(object_id(name), 'IsMsShipped') = 0
AND objectproperty(id, 'IsMsShipped') = 0
AND keycnt = 0
"JD" <JD@.discussions.microsoft.com> wrote in message
news:C554DC0B-22B6-4763-8A10-052843C5D47C@.microsoft.com...
> Is there a way to delete the indexes on all the tables for a specific
> database in SQL Server using Query Analyzer without knowing the exact name
> of
> the Index? I am able to do this using SQLDMO, but I need to know if there
> is
> a way to do this using Query Analyzer.
> Thanks|||hi,
if you know the name of the table using sp_help <table> you obtain the name
of its indexes.
regards,
"JD" wrote:

> Is there a way to delete the indexes on all the tables for a specific
> database in SQL Server using Query Analyzer without knowing the exact name
of
> the Index? I am able to do this using SQLDMO, but I need to know if there
is
> a way to do this using Query Analyzer.
> Thanks

Friday, March 9, 2012

Deleted Database

Accidently deleted a db and my backup is two weeks old...any way to recover
the db. It was a quirky thing, I was in query analyzer and I must have right
clicked and hit delete... I have a quirky laptop keyboard...anyway...is there
anyway to restore the deleted .mdf file? I am a relative newbie to this so
any help is appreciated.
Thanks...
Larry
Not through SQL Server or any of its tools. Post to a Windows forum to see if there exist any
undelete options. If you do manage, you can then try sp_attach_db of the database files.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"LarryF" <lawrencef14@.hotmail.com> wrote in message
news:5D55BD15-A94F-49C6-8032-4BCF77B129C4@.microsoft.com...
> Accidently deleted a db and my backup is two weeks old...any way to recover
> the db. It was a quirky thing, I was in query analyzer and I must have right
> clicked and hit delete... I have a quirky laptop keyboard...anyway...is there
> anyway to restore the deleted .mdf file? I am a relative newbie to this so
> any help is appreciated.
> Thanks...
> --
> Larry
|||thanks, i thought that was the answer...
Larry
"Tibor Karaszi" wrote:

> Not through SQL Server or any of its tools. Post to a Windows forum to see if there exist any
> undelete options. If you do manage, you can then try sp_attach_db of the database files.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "LarryF" <lawrencef14@.hotmail.com> wrote in message
> news:5D55BD15-A94F-49C6-8032-4BCF77B129C4@.microsoft.com...
>
>
|||When a file is deleted there is a record still kept on the hard drive.
Depending on the size of the database file it might have been actually
deleted from the hard drive but a small database < 1GB has a good chance of
still being there.
Google "undelete" and you'll find a number of tools out there that can
recover the file.
Good luck.
"LarryF" wrote:
[vbcol=seagreen]
> thanks, i thought that was the answer...
> --
> Larry
>
> "Tibor Karaszi" wrote:

Deleted Database

Accidently deleted a db and my backup is two weeks old...any way to recover
the db. It was a quirky thing, I was in query analyzer and I must have right
clicked and hit delete... I have a quirky laptop keyboard...anyway...is there
anyway to restore the deleted .mdf file? I am a relative newbie to this so
any help is appreciated.
Thanks...
--
LarryNot through SQL Server or any of its tools. Post to a Windows forum to see if there exist any
undelete options. If you do manage, you can then try sp_attach_db of the database files.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"LarryF" <lawrencef14@.hotmail.com> wrote in message
news:5D55BD15-A94F-49C6-8032-4BCF77B129C4@.microsoft.com...
> Accidently deleted a db and my backup is two weeks old...any way to recover
> the db. It was a quirky thing, I was in query analyzer and I must have right
> clicked and hit delete... I have a quirky laptop keyboard...anyway...is there
> anyway to restore the deleted .mdf file? I am a relative newbie to this so
> any help is appreciated.
> Thanks...
> --
> Larry|||thanks, i thought that was the answer...
--
Larry
"Tibor Karaszi" wrote:
> Not through SQL Server or any of its tools. Post to a Windows forum to see if there exist any
> undelete options. If you do manage, you can then try sp_attach_db of the database files.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "LarryF" <lawrencef14@.hotmail.com> wrote in message
> news:5D55BD15-A94F-49C6-8032-4BCF77B129C4@.microsoft.com...
> > Accidently deleted a db and my backup is two weeks old...any way to recover
> > the db. It was a quirky thing, I was in query analyzer and I must have right
> > clicked and hit delete... I have a quirky laptop keyboard...anyway...is there
> > anyway to restore the deleted .mdf file? I am a relative newbie to this so
> > any help is appreciated.
> >
> > Thanks...
> > --
> > Larry
>
>|||When a file is deleted there is a record still kept on the hard drive.
Depending on the size of the database file it might have been actually
deleted from the hard drive but a small database < 1GB has a good chance of
still being there.
Google "undelete" and you'll find a number of tools out there that can
recover the file.
Good luck.
"LarryF" wrote:
> thanks, i thought that was the answer...
> --
> Larry
>
> "Tibor Karaszi" wrote:
> > Not through SQL Server or any of its tools. Post to a Windows forum to see if there exist any
> > undelete options. If you do manage, you can then try sp_attach_db of the database files.
> >
> > --
> > Tibor Karaszi, SQL Server MVP
> > http://www.karaszi.com/sqlserver/default.asp
> > http://www.solidqualitylearning.com/
> >
> >
> > "LarryF" <lawrencef14@.hotmail.com> wrote in message
> > news:5D55BD15-A94F-49C6-8032-4BCF77B129C4@.microsoft.com...
> > > Accidently deleted a db and my backup is two weeks old...any way to recover
> > > the db. It was a quirky thing, I was in query analyzer and I must have right
> > > clicked and hit delete... I have a quirky laptop keyboard...anyway...is there
> > > anyway to restore the deleted .mdf file? I am a relative newbie to this so
> > > any help is appreciated.
> > >
> > > Thanks...
> > > --
> > > Larry
> >
> >
> >

Deleted Database

Accidently deleted a db and my backup is two weeks old...any way to recover
the db. It was a quirky thing, I was in query analyzer and I must have righ
t
clicked and hit delete... I have a quirky laptop keyboard...anyway...is ther
e
anyway to restore the deleted .mdf file? I am a relative newbie to this so
any help is appreciated.
Thanks...
--
LarryNot through SQL Server or any of its tools. Post to a Windows forum to see i
f there exist any
undelete options. If you do manage, you can then try sp_attach_db of the dat
abase files.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"LarryF" <lawrencef14@.hotmail.com> wrote in message
news:5D55BD15-A94F-49C6-8032-4BCF77B129C4@.microsoft.com...
> Accidently deleted a db and my backup is two weeks old...any way to recove
r
> the db. It was a quirky thing, I was in query analyzer and I must have ri
ght
> clicked and hit delete... I have a quirky laptop keyboard...anyway...is th
ere
> anyway to restore the deleted .mdf file? I am a relative newbie to this s
o
> any help is appreciated.
> Thanks...
> --
> Larry|||thanks, i thought that was the answer...
--
Larry
"Tibor Karaszi" wrote:

> Not through SQL Server or any of its tools. Post to a Windows forum to see
if there exist any
> undelete options. If you do manage, you can then try sp_attach_db of the d
atabase files.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "LarryF" <lawrencef14@.hotmail.com> wrote in message
> news:5D55BD15-A94F-49C6-8032-4BCF77B129C4@.microsoft.com...
>
>|||When a file is deleted there is a record still kept on the hard drive.
Depending on the size of the database file it might have been actually
deleted from the hard drive but a small database < 1GB has a good chance of
still being there.
Google "undelete" and you'll find a number of tools out there that can
recover the file.
Good luck.
"LarryF" wrote:
[vbcol=seagreen]
> thanks, i thought that was the answer...
> --
> Larry
>
> "Tibor Karaszi" wrote:
>