Monday, March 19, 2012
How to re-directory of Master and model dbs
Anyone know how to change the directory of system dbs -- master and model dbs? Thanks.I mean changing the directory of system db data files.|||http://support.microsoft.com/default.aspx?scid=kb;en-us;224071
Tim S|||Check these links:
http://www.databasejournal.com/features/mssql/article.php/1458131
http://www.sqlteam.com/item.asp?ItemID=10060
http://support.microsoft.com/default.aspx?scid=kb;EN-US;224071|||Hi Guys,
I tried to use the infor you guys providing for me to moved the msdb, was ok. but as moving Master db, I changed the startup Parameters using new location, then tried to restart the SQL server which was failed, got error message:"Could not start the MSSqlserver service on local computer. Error 1067: The process terminated unexpectedly".
Any suggestiongs??
Thanks.|||Did you move MDF and LDF files to the location that you specified in startup parameters?|||Yes, I moved both of them.|||Did you move anything else like MODEL?|||No, I didn't move Model only Master.|||This is the steps I did:
Moving the master database
1. Change the path for the master data and log files in SQL Server Enterprise Manager.
Note You may optionally change the location of the error log here as well.
2. Right-click the SQL Server in Enterprise Manager and click Properties.
3. Click the Startup Parameters button and you will see the following entries: -dD:\MSSQL7\data\master.mdf
-eD:\MSSQL7\log\ErrorLog
-lD:\MSSQL7\data\mastlog.ldf
-d is the fully qualified path for the master database data file.
-e is the fully qualified path for the error log file.
-l is the fully qualified path for the master database log file.
4. Change these values as follows: a. Remove the current entries for the Master.mdf and Mastlog.ldf files.
b. Add new entries specifying the new location: -dE:\SQLDATA\master.mdf
-lE:\SQLDATA\mastlog.ldf
5. Stop SQL Server.
6. Copy the Master.mdf and Mastlog.ldf files to the new location (E:\Sqldata).
7. Restart SQL Server.
Now last step was failed. Failed to restart SQL server. The error is " An error 1058 -- ( The service connot be started, either because it is disabled or because it has no enabled devices asociated with it ) occurred while performing this service operation on the MSSQL server service.
Any solutions Please? Thanks.|||Hi,
I checked the service porperty--Log on button-- Hardware Profile, disabled it and enabled it , then start the service again, the previous error message just gone , but other error coming out"Could not start the MSSqlserver service on local computer. Error 1067: The process terminated unexpectedly". I checked all possibility, but still no any clues.
Help !!!! Please!!!|||Try checking the sql server logs, event viewer to have an indication of what is going wrong ...|||I checked both of them yesterday: event view was empty, and sql server error log is :
2004-10-13 14:15:30.53 spid51 Configuration option 'show advanced options' changed from 1 to 1. Run the RECONFIGURE statement to install..
2004-10-13 14:15:30.64 spid51 Using 'xplog70.dll' version '2000.80.760' to execute extended stored procedure 'xp_msver'.
2004-10-13 14:26:20.26 spid2 SQL Server is terminating due to 'stop' request from Service Control Manager."
I tried to put the original startup parameters back at MSSQL service property window on log on button-- startup parameter.
it's still failed and nothing recorded at event view and error log too.|||I think you have a typo in the "Startup Parameters"
I Might be able to help you fix it, but need more info.
What is the exact paths to the following files?
master.mdf
ERRORLOG
mastlog.ldf
What OS are you running?
I am assuming SQL 2000 SP3, correct?
Tim S|||Thanks a lot Tim.
My OS is window 2000, and Sql server is sp3. The Mater original path is :
-dD:\Database Files\MSSQL\Data\master.mdf
-eD:\Database Files\MSSQL\Data\Log\ERRORLog
-lD:\Database Files\MSSQL\Data\mastlog.ldf
The new path I changed is:
-dD:\Database Files\Master\master.mdf
-eD:\Database Files\MSSQL\Data\Log\ERRORLog (this one was not changed)
-lD:\Log Files\Master\mastlog.ldf
Thanks.|||REGEDIT4
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\ MSSQLServer\Parameters]
"SQLArg0"="-dD:\\Database Files\\Master\\master.mdf"
"SQLArg1"="-eD:\\Database Files\\MSSQL\\Data\\Log\\ERRORLOG"
"SQLArg2"="-lD:\\Log Files\\Master\\mastlog.ldf"
Save above in a file ending with .reg
Then Click on the file This will set the default instance of SQL Server to the paths you gave for the master.
If it was just a typo should fix it.
Tim S|||Well, your error just does not make any sense, unless you misspelled the location of the files. It's that simple! No misteries! SQL Server service will start with -d and -l parameters for as long as the path specified actually contains the MDF and LDF files for master (providing nothing else got screwed up). Check the spelling and make sure you tell us the truth, otherwise, - you are making us all feel unworthy ;)|||Help!!!!!Please.|||Since you can't seem to figure out where sql server is looking for the master database, you might have to use the rebuildm utility to let sql server create a new set of system databases and then replace the newly created databases with yours by copying them over. Then you can try moving them again with the help in this thread, because it works if done right.
Be sure to stop sql sever and copy your system databases to a safe location (where they will not be overwritten !!) before running the utility. Also, read this first ... http://support.microsoft.com/default.aspx?scid=kb;en-us;273572|||Rebuild might be the last way.
I just don't get it: I check the registry, all the path in parameter folder are correct, no typo error and I tried to change back to original path, it's still not working. The error message is the same.
Any sugestions!!!!!
Thanks!
How to recover Master database table data
We here have an script that delete all data from all user tables of a database, and I run it in the master DATABASE.
As we don't made backups of this database, now somethings of the database aren't working.
Here is the script:
declare @.table_name sysname
declare @.alter_table_statement varchar(256)
declare @.delete_statement varchar(256)
-- definindo o cursor...
declare table_name_cursor cursor local fast_forward for
select
name
from
sysobjects
where
xtype = 'U'
and
name <> 'dtproperties'
-- desligando os vĂnculos...
open table_name_cursor
fetch next from table_name_cursor into @.table_name
select @.alter_table_statement = 'alter table ' + ltrim(rtrim(@.table_name)) + ' nocheck constraint all'
exec(@.alter_table_statement)
while @.@.Fetch_Status = 0
begin
fetch next from table_name_cursor into @.table_name
select @.alter_table_statement = 'alter table ' + ltrim(rtrim(@.table_name)) + ' nocheck constraint all'
exec(@.alter_table_statement)
end
close table_name_cursor
open table_name_cursor
fetch next from table_name_cursor into @.table_name
select @.delete_statement = 'delete from ' + ltrim(rtrim(@.table_name))
exec(@.delete_statement)
while @.@.Fetch_Status = 0
begin
fetch next from table_name_cursor into @.table_name
select @.delete_statement = 'delete from ' + ltrim(rtrim(@.table_name))
exec(@.delete_statement)
end
close table_name_cursor
open table_name_cursor
fetch next from table_name_cursor into @.table_name
select @.alter_table_statement = 'alter table ' + ltrim(rtrim(@.table_name)) + ' check constraint all'
exec(@.alter_table_statement)
while @.@.Fetch_Status = 0
begin
fetch next from table_name_cursor into @.table_name
select @.alter_table_statement = 'alter table ' + ltrim(rtrim(@.table_name)) + ' check constraint all'
exec(@.alter_table_statement)
end
close table_name_cursor
deallocate table_name_cursor
I have tried to restore master table with the restore function, but it doesn't work. When I try to do this I received a message informing that it can't copy the data because one file was in use. The server was in a single user mode.
Is there anyway to recover the data that I have lost?
Help me understand this.
At the beginning, you say that you don't have backups of the master database.
At the end you say that you tried to restore the master database, but had problems.
You should be able to restore the master database if you have a backup of it, and this would be the best method to use.
Can you clarify, and also let us know what method (T-SQL commands etc.) you used to attempt the restore?
|||Kevin don't have any backup of this database, I tried to rebuild it, not restore it, I used the wrong word for it.|||There isn't any easy answer to this. If you have already rebuilt master then you should have SQL Server up and running with a clean master. Realize that by rebuilding the master database all your jobs and maintenance plans in MSDB have been lost, unless you have a backup of msdb or scripts to recreate the jobs.
The datafiles for your user databases should still be on the disk, you will need to attach those using sp_attach_db.
Once you have the databases attached you still won't have the logins. You will need to recreate the logins, then remap those new logins using the procedure outlined in http://support.microsoft.com/kb/274188/en-us
|||Ok thanks... one more explanation
In fact my real problem isn't on the databases and user logins, becaus this I doesn't lost. I lost the access to table metadata (via jdbc driver) and the permission to create diagrams. Probably this can be done by reconfiguring the server, but I doesn't know how to do it.
How to recover master database
to master database?Lorena
if you mean copy between master in one installation and master in =
another you could use DTS, linked servers or a variety of other options, =
but it all depneds what you are trying to recover from where and to =
where, can you post some more details?
Mike John
"Lorena" <anonymous@.discussions.microsoft.com> wrote in message =
news:d71701c40de3$4f81cb20$a601280a@.phx.gbl...
> How Do I do to recover information from master database
> to master database?
>|||My database master was destroided, but I have a full
backup of master database, but i can't recover it, show
me the next message. RESTORE DATABASE must be used in
single user mode when trying to restore the master
database
I need recover information about the aplicactions users.
Thanks
Lorena
>--Original Message--
>Lorena
>if you mean copy between master in one installation and
master in another you could use DTS, linked servers or a
variety of other options, but it all depneds what you are
trying to recover from where and to where, can you post
some more details?
>Mike John
>"Lorena" <anonymous@.discussions.microsoft.com> wrote in
message news:d71701c40de3$4f81cb20$a601280a@.phx.gbl...
>.
>|||If you search for below in Books Online, you find instructions on how to
start SQL Server in single user mode:
"restore master"
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
"Lorena" <anonymous@.discussions.microsoft.com> wrote in message
news:bb8d01c40de8$f50d2670$a001280a@.phx.gbl...
> My database master was destroided, but I have a full
> backup of master database, but i can't recover it, show
> me the next message. RESTORE DATABASE must be used in
> single user mode when trying to restore the master
> database
> I need recover information about the aplicactions users.
> Thanks
> Lorena
>
>
> master in another you could use DTS, linked servers or a
> variety of other options, but it all depneds what you are
> trying to recover from where and to where, can you post
> some more details?
> message news:d71701c40de3$4f81cb20$a601280a@.phx.gbl...|||Hi,
Steps:
1. Stop MSSQL server Service from Control panel
2. Execute sqlservr.exe -c -m from command prompt
3. Restore the Master database backup using RESTORE DATABASE
4. Once all the activies are over Press COntrol break in key board to stop
MS Sqlserver
5. Restart SQL server from COntrol panel services as normal.
Consider the below after master restore
a. If the Master backup is old, then any database users previously
associated with logins that need to be re-created .
b. If any user databases were created after Master db was backed up, those
databases will not be available.Use SP_Attach_db to
attach those databases to avoid restore time. If attach gives issues
then try restoring from backup.
Thanks
Hari
MCDBA
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:ezAvumeDEHA.2932@.tk2msftngp13.phx.gbl...
> If you search for below in Books Online, you find instructions on how to
> start SQL Server in single user mode:
> "restore master"
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
>
> "Lorena" <anonymous@.discussions.microsoft.com> wrote in message
> news:bb8d01c40de8$f50d2670$a001280a@.phx.gbl...
>
How to recover deleted data from master database
I made a horrible thing this week. I have an script that delete all data from all user tables, and I run it in the master database.
After this I couldn't access the metadata from the tables of my databases using a JDBC connection.
My script runs over all sysobject that are different from dtproperties.
I don't have a back up of master table. I have tried to copy the data from another master database (from another machine) but I did not work. I tried to copy from a xls, but it did'nt work too. I try do recover the master database (as it is explained in the online books) but it did not work either.
Someone know how can I recover this data?Here is the script:
declare @.table_name sysname
declare @.alter_table_statement varchar(256)
declare @.delete_statement varchar(256)
declare table_name_cursor cursor local fast_forward for
select
name
from
sysobjects
where
xtype = 'U'
and
name <> 'dtproperties'
open table_name_cursor
fetch next from table_name_cursor into @.table_name
select @.alter_table_statement = 'alter table ' + ltrim(rtrim(@.table_name)) + ' nocheck constraint all'
exec(@.alter_table_statement)
while @.@.Fetch_Status = 0
begin
fetch next from table_name_cursor into @.table_name
select @.alter_table_statement = 'alter table ' + ltrim(rtrim(@.table_name)) + ' nocheck constraint all'
exec(@.alter_table_statement)
end
close table_name_cursor
open table_name_cursor
fetch next from table_name_cursor into @.table_name
select @.delete_statement = 'delete from ' + ltrim(rtrim(@.table_name))
exec(@.delete_statement)
while @.@.Fetch_Status = 0
begin
fetch next from table_name_cursor into @.table_name
select @.delete_statement = 'delete from ' + ltrim(rtrim(@.table_name))
exec(@.delete_statement)
end
close table_name_cursor
-- ligando os vnculos...
open table_name_cursor
fetch next from table_name_cursor into @.table_name
select @.alter_table_statement = 'alter table ' + ltrim(rtrim(@.table_name)) + ' check constraint all'
exec(@.alter_table_statement)
while @.@.Fetch_Status = 0
begin
fetch next from table_name_cursor into @.table_name
select @.alter_table_statement = 'alter table ' + ltrim(rtrim(@.table_name)) + ' check constraint all'
exec(@.alter_table_statement)
end
close table_name_cursor
deallocate table_name_cursor
And here is the names of the tables of master database that this script had deleted all the containing data:
spt_monitor
spt_values
spt_fallback_db
spt_fallback_dev
spt_fallback_usg
spt_provider_types
spt_datatype_info_ext
MSreplication_options
spt_datatype_info
spt_server_info
spt_server_info
Monday, March 12, 2012
How to rebuild/rescover the master database in sql 2005
Thanks, Mike
I've tried using the below query and it has rebuilded the master database...........
start /wait <CD or DVD Drive>\setup.exe /qn INSTANCENAME="InstanceName" REINSTALL=SQL_Engine REBUILDDATABASE=1 SAPWD="NewStrongPassword"
if you have master db backup you can restore it in single user mode as follows,
go to command prompt and type the below command
NET START MSSQLSERVER /c /m then perform the restoration it will work.............
|||Deepak, did you have a master.mdf to start with? In my test, I have none of the master.mdf and other supporting db files to start with. Then you use the "start /wait setup.exe......" and next the "NET START......." and recover?
Thanks, Mike
|||Well, almost got it to work. Now if fails and says my password does not meet the password policy, password is to short..... I'm using a 15 character password. Shouldn't this work? Thanks, Mike
|||Mike,
Pls refer the link, http://deepakinsql.blogspot.com/2007/08/how-to-rebuild-system-database-in-sql.html
I've tried it and its working for me. I've posted it in my blog.....pls check and let me know if it works
Thanxx
Deepak
|||Deepak, I'm out of the office this week, I will take a look at this later. Thanks for the update. MikeHow to rebuild/rescover the master database in sql 2005
Thanks, Mike
I've tried using the below query and it has rebuilded the master database...........
start /wait <CD or DVD Drive>\setup.exe /qn INSTANCENAME="InstanceName" REINSTALL=SQL_Engine REBUILDDATABASE=1 SAPWD="NewStrongPassword"
if you have master db backup you can restore it in single user mode as follows,
go to command prompt and type the below command
NET START MSSQLSERVER /c /m then perform the restoration it will work.............
|||Deepak, did you have a master.mdf to start with? In my test, I have none of the master.mdf and other supporting db files to start with. Then you use the "start /wait setup.exe......" and next the "NET START......." and recover?
Thanks, Mike
|||Well, almost got it to work. Now if fails and says my password does not meet the password policy, password is to short..... I'm using a 15 character password. Shouldn't this work? Thanks, Mike
|||Mike,
Pls refer the link, http://deepakinsql.blogspot.com/2007/08/how-to-rebuild-system-database-in-sql.html
I've tried it and its working for me. I've posted it in my blog.....pls check and let me know if it works
Thanxx
Deepak
|||Deepak, I'm out of the office this week, I will take a look at this later. Thanks for the update. MikeHow to rebuild/rescover the master database in sql 2005
Thanks, Mike
I've tried using the below query and it has rebuilded the master database...........
start /wait <CD or DVD Drive>\setup.exe /qn INSTANCENAME="InstanceName" REINSTALL=SQL_Engine REBUILDDATABASE=1 SAPWD="NewStrongPassword"
if you have master db backup you can restore it in single user mode as follows,
go to command prompt and type the below command
NET START MSSQLSERVER /c /m then perform the restoration it will work.............
|||Deepak, did you have a master.mdf to start with? In my test, I have none of the master.mdf and other supporting db files to start with. Then you use the "start /wait setup.exe......" and next the "NET START......." and recover?
Thanks, Mike
|||Well, almost got it to work. Now if fails and says my password does not meet the password policy, password is to short..... I'm using a 15 character password. Shouldn't this work? Thanks, Mike
|||Mike,
Pls refer the link, http://deepakinsql.blogspot.com/2007/08/how-to-rebuild-system-database-in-sql.html
I've tried it and its working for me. I've posted it in my blog.....pls check and let me know if it works
Thanxx
Deepak
|||Deepak, I'm out of the office this week, I will take a look at this later. Thanks for the update. MikeHow to rebuild the master database.?
Installed SQLSERVER 2005 EVAL copy in my server and trying to rebuild the master database and it is not working.
I tried the following command.
start /wait setup.exe /qn INSTANCENAME=MSSQLSERVER REINSTALL=SQL_Engine REBUILDDATABASE=1 SAPWD=RAJESH
Any thoughts?
Thanks
First off, can you help me understand why you need to rebuild master instead of restoring from backup? Rebuilding master is typically done when it is too corrupt to allow the instance to start.
If the instance is running, that would probably prevent the procedure above from working. It isn't intended for running instances.
If your instance is down and it still doesn't work, please post the exact error message and we'll see what we can find out.
Sunday, February 19, 2012
How to query master table in Query Analyzer?
select id from sysindexes where (name ='customers')
and I've got the ID of the table.
In query analyzer, I executed:
use master; select id from sysindexes where (name ='customers')
and I don't have the value.
What is the right way to query the sysindexes from Query Anal?
Thanks.
light_wt wrote:
> In Enterprise Manager, I executed:
> select id from sysindexes where (name ='customers')
> and I've got the ID of the table.
> In query analyzer, I executed:
> use master; select id from sysindexes where (name ='customers')
> and I don't have the value.
> What is the right way to query the sysindexes from Query Anal?
> Thanks.
Sysindexes is a system table that resides in all databases. From QA use
the correct database first and then query sysindexes.
David G.
|||Thanks, David.
There is "use master;".
|||Which is exactly what you should remove.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"light_wt" <lightwt@.discussions.microsoft.com> wrote in message
news:FC3636CE-9987-4E38-8E32-230E78F85584@.microsoft.com...
> Thanks, David.
> There is "use master;".
|||light_wt wrote:
> Thanks, David.
> There is "use master;".
As Tibor said, remove that line. The Sysindexes you want to query is not
in the master database (unless you are installing user tables there).
Use the correct database first... which is not Master.
David G.
How to query master table in Query Analyzer?
select id from sysindexes where (name ='customers')
and I've got the ID of the table.
In query analyzer, I executed:
use master; select id from sysindexes where (name ='customers')
and I don't have the value.
What is the right way to query the sysindexes from Query Anal?
Thanks.light_wt wrote:
> In Enterprise Manager, I executed:
> select id from sysindexes where (name ='customers')
> and I've got the ID of the table.
> In query analyzer, I executed:
> use master; select id from sysindexes where (name ='customers')
> and I don't have the value.
> What is the right way to query the sysindexes from Query Anal?
> Thanks.
Sysindexes is a system table that resides in all databases. From QA use
the correct database first and then query sysindexes.
--
David G.|||Thanks, David.
There is "use master;".|||Which is exactly what you should remove.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"light_wt" <lightwt@.discussions.microsoft.com> wrote in message
news:FC3636CE-9987-4E38-8E32-230E78F85584@.microsoft.com...
> Thanks, David.
> There is "use master;".|||light_wt wrote:
> Thanks, David.
> There is "use master;".
As Tibor said, remove that line. The Sysindexes you want to query is not
in the master database (unless you are installing user tables there).
Use the correct database first... which is not Master.
--
David G.
How to query master table in Query Analyzer?
select id from sysindexes where (name ='customers')
and I've got the ID of the table.
In query analyzer, I executed:
use master; select id from sysindexes where (name ='customers')
and I don't have the value.
What is the right way to query the sysindexes from Query Anal?
Thanks.light_wt wrote:
> In Enterprise Manager, I executed:
> select id from sysindexes where (name ='customers')
> and I've got the ID of the table.
> In query analyzer, I executed:
> use master; select id from sysindexes where (name ='customers')
> and I don't have the value.
> What is the right way to query the sysindexes from Query Anal?
> Thanks.
Sysindexes is a system table that resides in all databases. From QA use
the correct database first and then query sysindexes.
David G.|||Thanks, David.
There is "use master;".|||Which is exactly what you should remove.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"light_wt" <lightwt@.discussions.microsoft.com> wrote in message
news:FC3636CE-9987-4E38-8E32-230E78F85584@.microsoft.com...
> Thanks, David.
> There is "use master;".|||light_wt wrote:
> Thanks, David.
> There is "use master;".
As Tibor said, remove that line. The Sysindexes you want to query is not
in the master database (unless you are installing user tables there).
Use the correct database first... which is not Master.
David G.
How to query a view from the master DB?
I'm getting this error
Invalid object name 'v_StatisticsScalars'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Invalid object name 'v_StatisticsScalars'.Use the fully qualified path <database>.<owner>.<view
Or you can use "use"|||cant use USE in stored procedures can you?
im using system stored procedures.....and i thought the context stayed at the database calling the system stored procedure? am i wrong?|||i really dont want to use x.y.z because im using these stored procedures for a few different sites. it would be good if i could add the view to the master database. can that be done? i tried....but then it says my tables dont exist. :/ -so now im back at square1|||Now I'm confused too. I understand that you're relucant to use the fully qualified path. I don't understand what you mean by "I'm using system stored procedures". You can create a view to access other database table but we're back to using the fully qualified path again! If the database was on a different server (or server instance) you could setup a linked server. Apart from that I think you're stuck. Well you could construct some dynamic sql and exec that to get around the 'different sites' issue. In fact just have a util prog that generates the procs/views based upon the database names you want to use.