Recreating DB Log Files

Jul 25, 2004

I would like to be able to regenerate the log files for our SQL databases without impacting the data files. I tried:
- detaching the database,
- saving the datafiles to another drive,
- dropping and recreating the database with the same structure as before,
- detaching the database again,
- overlaying the data files with the ones I saved previously,
- then reattaching the database.

The reattach fails saying that the files can't be used for different databases.
If I try to bring in log files that are the same size as the database log files I'm trying to recreate, I get the same error only the log files are the ones in error.
I've tried recovering/recreating the database with the "for attach" parameter, but I get the same error.

More information... The problem I'm having that requires the log files to be regenerated is realted to an upgrade to Win 2003 EE. We upgraded the server last week and since then, the backups have been failing. I've tried reloading a backup of the database but the only backups we have are prior to the upgrade and I think, because the database logs are operating system files, the logs don't get loaded correctly and I still have the same backup problem. I logged a case with Microsoft, but they haven't been able to help.

View 3 Replies


ADVERTISEMENT

Recreating A View

Oct 19, 2007



I have some tables that are created as views in a database.
Everytime I modify table structure the view needs to be recreated.

I am developing a simple Stored Procedure which takes table name as parameter and drops teh view first and then cretaes it again.
The statements required would be

drop view viewname
create view viewname as
select * from ffship.dbo.viewname


The error I get is that

'CREATE VIEW' must be the first statement in a query batch

Any help appreciated.

Thanks,
Kiran.

View 4 Replies View Related

Problem Recreating The Database

Mar 25, 2008

Then I deleted an entire database from the "Enterprise Manager". And refreshed the Query Analyzer.
Then I again tried to create the database.  CREATE DATABASE ContactManager ON PRIMARY(NAME = ContactManager,FILENAME ='C:Program FilesMicrosoft SQL ServerMSSQLDataContactManager.mdf',SIZE = 5MB,MAXSIZE = 20MB,FILEGROWTH = 5MB)LOG ON(NAME = ContactManager,FILENAME = 'C:Program FilesMicrosoft SQL ServerMSSQLDataContactManager.ldf',SIZE = 2MB,MAXSIZE = 10MB,FILEGROWTH = 2MB)GoNow it says, database already exists.
I used 'EXEC sp_helpdb' to view all the databases, but the database 'ContactManager' was not there.
Where is the problem?

 

View 1 Replies View Related

Recreating Log File For Sql Server 7

Oct 2, 2000

I have a client who was cleaning up his server to free up disk space and actualy deleted de transaction log file for server database. I can't bring back the backup because it was also deleted (smart...). I still have the .mdf file. Is there a way to bring back the database? I tried to detach and reatach database without success, so the database is no longer attached.

Any help would really help.

Thanks in advance,
Stephane Jeffrey

View 2 Replies View Related

Recreating Indexes Dynamically

Apr 22, 2003

How to get all the index properties like unique, clustered of an index.

I need to recreate all the indexes in a table dynamically
1) need to get the list of indexes
2) drop them
3) change some properties and recreate the indexes, to do this I need to know the columns, uniqueness, clusteredness in step 1 above. How can I get to that?

In oracle we can depend on tables like index_columns, index_constraints....

thx

View 2 Replies View Related

Recreating A Corrupt Database!

Nov 3, 1998

Hello all,

I'm in a bit of a bind. We have a database that spits out a classic corruption error message whenever attempting to run scheduled maintenance:

Error:605, Severity: 21, State: 1
Attempt to fetch logical page ### in databbase 'db1' belongs to object 'table1' not object 'table2'

SQL Books Online says to check with DBCC checkDB and CheckAlloc asap, which I did, and CheckAlloc confirmed the corruption. Books Online's only advice at this point is to restore the DB from a clean backup.

Herein lies the problem. One I'm assuming has happened to many a DBA as well.

This particular message has been going on for months, and there is no "clean" backup of the database, because no-one here at the time knew there were any problems to take precautions. Now I'm here with a corrupt database, and no idea how one goes about reconstructing a DB from scratch. Does anybody out there know any good options?

Thanks in Advance

Fenderson

View 4 Replies View Related

Dropping Indexes And Recreating The Same

May 1, 2008

I would like to know if there is a way to drop/ disenable all the indexes in a maintenance plan?
Or is it better to write scripts for dropping indexes and recreatig the same?

Purpose: Need to drop indexes(not the Primary key) before loading data and recreate the same after loading

Looking forward for suggestions/Solutions!

Thanks,
Janani

View 2 Replies View Related

T-SQL And Dropping And Recreating A Table

Jun 11, 2008

Hi Guys,

I am trying to DROP a table and recreate the table in a stored procedure and then I am trying to INSERT records into the newly created table in the same stored procedure.

I know I don't have to DROP the table, but I am trying to just get it to work. The process runs without error, but when I refresh the tables, the table I created isn't there. The T-SQL is as follows:


set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[ImportFilesPremier]

AS

DROP TABLE dbo.[PremierTest]

CREATE TABLE [PremierTest] (
[AYQ] nvarchar(6) null ,
[CYQ] nvarchar(6) null ,
[Description] nvarchar(50) null,
[PIP] [decimal] (17,2) ,
[BI] [decimal](17,2) Not null,
[PD] [decimal](17,2) Not null,
[COLL] [decimal](17,2) not null,
[COMP] [decimal](17,2) not null,
[DCRAT] [nvarchar](2) null ,
[Agent][nvarchar](3) null ,
) ON [PRIMARY]

begin transaction

insert into [PremierTest]
select *
from dbo.[new agt type tri 0804]
WHERE dir_ceded_ind = 'C'

commit transaction


Any information on how I can tweak my code so it works properly would be greatly appreciated. Thank you.

View 4 Replies View Related

Deleting Users And Recreating

May 7, 2006

In my database, I am currently trying to delete a user and recreate it for ownership. I get the following error message

An exception ocurred while executing a Transact-SQL statement or batch. The database principal owns a schema in the database and cannot be dropped. SQL Server Error 15138.

What do I need to do? Thanks

David

View 1 Replies View Related

Recreating Index After Restore--URGENT PLEASE

Sep 4, 2002

Hi all,
I have created a new database from a backup. When I run the application, it seems like it is not getting the right indexes but it is in Development environment. So, I ran a script to recreate the index by DBCC DBREINDEX(TABLENAME). Still not getting it right. mainly it is not using the primary key index. I believe that dbcc dbrenindex will also reindex primarykey indexes. Any one know, how to overcome this problem. It is a production issue and I would appreciate for your prompt advise.
Note: Does anyone has any script to drop the primarykey index and to recreate it.
Thanks,
Joe

View 1 Replies View Related

Recreating ODBC Connection Strings

Jul 11, 2002

Due to some problems, we have to reformat Our Windows NT4.0 Server.
The SQL Server 2000 has several ODBC Configured as
"User DSN" and "System DSN" .

Question: Is there any way that we could copy these User DSN and System DSN
Config Files so that after Rebuilding Server AND Database, we could Re-aaply/
Re-create these ODBC DSN specifically "System DSN" as they are More Number.

Thanks

View 1 Replies View Related

Recreating ODBC Connection Strings

Jul 11, 2002

Due to some problems, we have to reformat Our Windows NT4.0 Server.
The SQL Server 2000 has several ODBC Configured as
"User DSN" and "System DSN" .

Question: Is there any way that we could copy these User DSN and System DSN
Config Files so that after Rebuilding Server AND Database, we could Re-aaply/
Re-create these ODBC DSN specifically "System DSN" as they are More Number.

Thanks

View 1 Replies View Related

Recreating Indexes After Restore. Urgent -- Please

Sep 4, 2002

Hi all,
I have created a new database from a backup. When I run the application, it seems like it is not getting the right indexes but it is in Development environment. So, I ran a script to recreate the index by DBCC DBREINDEX(TABLENAME). Still not getting it right. mainly it is not using the primary key index. I believe that dbcc dbrenindex will also reindex primarykey indexes. Any one know, how to overcome this problem. It is a production issue and I would appreciate for your prompt advise. I have also ran the update statistics on all tables but with no luck
Note: Does anyone has any script to drop the primarykey index and to recreate it.
Thanks,
Joe

View 2 Replies View Related

Dropping And Recreating Stored Procedure?

Feb 16, 2015

Due to some SSQL application upgrade, some unnecessary columns have been added to the tables and the stored procedures. The values in these columns are NULL and these columns have been added at the end of the tables and some SP.

As my application doesn't require these columns thereby I have re-created the old tables using other environments where these columns were not present.

Can I do the same thing for stored procedures as well i.e. to drop the SP and recreate using other environment which are not having the unnecessary columns.

View 5 Replies View Related

Recreating The Data Publishing Wizard

Mar 27, 2008

Hi,
I was wondering if anyone had an idea if it's possible to run a stored procedure that would basically output a .sql file used to recreate the database elsewhere. kinda like the data publishing wizard does.

?
tx

View 1 Replies View Related

Recreating/reloading System Stored Procedures

Jul 21, 2006

A system stored procedure got accidentally deleted, and all backups aresince the stored procedure was deleted (wonderful!)Can the SQL for the stored procedure be extracted from another serverand loaded as opposed to removing everything and then rebuilding theserver?Thanks in advance!

View 1 Replies View Related

Merge Replication Failing After Recreating The Publication

Jun 7, 2006

I am having a problem with merge replication after recreating a publication. It is a simple two-way replication between two servers allowing applications to update data at both ends, i.e. 1 publisher, 1 subscriber for all tables except some junk ones. The problem started after I did the following:

1) I dropped and recreated the publication to allow for some changes to the database schema. These caused problems so I dropped the subscription and publication and restored the databases at each end from backups taken before we started.

2) When I created the publication again, it wouldn't let me use the same name as it thought the publication already existed. It let me use a different name instead.

3) Most things work OK but one of the tables is not replicating inserts from the subscriber to the publisher. There are no errors and no conflicts, other similar tables replicate OK. Inserts go across the other way OK.

4) I am getting replication conflicts on another table that says 'Unable to synchronize the row because the row was updated by a different process outside of replication'

I believe the problem is to do with the original publication details still being in the restored databases, so am looking to drop the publication & subscription, remove the remnants of the old publication, fix the data and recreate pub & sub. What do I need to do to get rid of the old replication data in the database?

Any help much appreciated.



View 4 Replies View Related

How To Add Tabls To Published Article Without Recreating Snapshot?

Jan 26, 2007

Hi experts:

We have 4 SQL SERVER 2000 servers linked via replication, and due to business changes we have to add one table to the published databases. And the existed database has more than 20g, recreating the snapshot and re-init replication is not allowed as the business cannot be stopped more than 1 hour. So my question is how to add tables to the published article without recreating the snapshot?

By that is not possilbe, can we publish one new article on the same database?



Thanks in advance!

Ron

View 1 Replies View Related

Altering (or Recreating) A Stored Procedure Header

May 30, 2006

We are using SQL Server 2005 to develop a simple SP. We started by including an output parameter which would report back the identity of the record being inserted or updated. We have since been trying to drop and recreate the SP without the output parameter, or alter the SP with the same outcome in mind. Neither has been succeeding, as confirmed by inspection of the sys.objects and sys.parameters tables. What might we be missing? We are using the Developer Edition, which may or may not be adequate to the task. Or maybe earlier versions of SQL Server are more robust and would be more successful to help us succeed? Please advise. Thank you.

View 5 Replies View Related

Recreating The Functionality Of A Extended Stored Procedure That Uses Srv_impersonate_client

Mar 1, 2006

I need help rewriting an extended stored procedure as a CLR.

What this extended stored procedure does is to return the domain username of the person connected via named pipes.

This is accomplished by using the srv_impersonate_client and GetUserName functions from opends60.lib. I have tried rewriting this in CLR using Microsoft.SQLServer.Server.SQLContext.WindowsIdentity but have been unable to replicate the functionality to return the same values as the srv_impersonate_client.

If anyone knows how I can rewrite this as CLR, let me know, Also I am looking for where I can get a 64bit version of opends60.lib to run on an amd64

Thanks
Darryl

View 6 Replies View Related

How To Alter The Table With Delete/update Cascade Without Recreating The Table

Jul 26, 2004

I have contract table which has built in foreign key constrains. How can I alter this table for delete/ update cascade without recreating the table so whenever studentId/ contactId is modified, the change is effected to the contract table.

Thanks


************************************************** ******
Contract table DDL is

create table contract(
contractNum int identity(1,1) primary key,
contractDate smalldatetime not null,
tuition money not null,
studentId char(4) not null foreign key references student (studentId),
contactId int not null foreign key references contact (contactId)
);

View 3 Replies View Related

Regarding ReCreating Catalog In SQL Server 2005 Which Was Existing In SQL Server 2000

Feb 24, 2008



Hello

I was using SQL SERVER 2000 ... In one table I've created FULL TEXT SEARCHING ( Full text catalog along with full text indexing)

Now we had to install our db in SQL SERVER 2005 standard edition. But while taking script it gave me two lines like:


if (select DATABASEPROPERTY(DB_NAME(), N'IsFullTextEnabled')) <> 1
exec sp_fulltext_database N'enable'
GO
if not exists (select * from dbo.sysfulltextcatalogs where name = N'DEV_CAS_DiagnosisCatalog')
exec sp_fulltext_catalog N'DEV_CAS_DiagnosisCatalog', N'create'
GO

so I used this in the new db creation script...

But I couldn't get where it actually is in SQL SERVER 2005 standard edition.

and also plz help how should we create if it doesn't exist...

What could be the problem....

Thanks In advance

View 3 Replies View Related

Recreating A Sql Server 2000 Database As A 2005 Database

Jan 25, 2007

 
I am working on a project that was written in Visual Studio 2003 using asp.net and C#.  The project accesses a SQL Server 2000 database. I need to test the application. What I want to do is to copy the database over to a test server. The problem is that the test server only has SQL Server 2005 on it. Would it be a problem if I backed up the database using SQL Server 2000 and then recreated it on the server as a SQL server 2005 project? Would my source code accept the new database even though it would now be in sql server 2005? 
 

View 2 Replies View Related

SQL Server Admin 2014 :: Separate Data Files / Log Files / TempDB / Backups

Jan 9, 2015

I proposed on a new server that we separate Data Files, Log Files, tempDB, Backups, etc. onto separate LUNS on a SAN with High Speed Solid State Drives.I was told that with the new technology with solid state SAN's that it would decrease performance and that it did not work the same way as it did when you had RAID 5's etc.I thought that if things were cared out correctly by a SAN Administrator they would know how to configure for optimal performance.

View 2 Replies View Related

For Loop - Iterate From Older Files To Newer Files Based On File's Timestamp

Mar 13, 2008

In the For Loop, How to Iterate from Older flat files to Newer flat files based on File's Timestamp. If there are some older files in that folder, it should be processed first and then continue with the newer one.

Any Suggestions?

View 3 Replies View Related

Script Task: How To Compare Files On FTP With Existing Files In Local Folder Before Transfer!

Apr 24, 2008

In the first step of my SSIS package I need to get files from FTP and dump it/them in a local directory, but it's more than that, the logic is like this:
1. If no file(s) found, stop executing and send email saying no file(s) found;
2. If file(s) found, then compare it/them with existing files in our archive folder; if file(s) already exist in archive folder, stop executing and send email saying file(s) already existed, if file(s) not in archive folder yet, then transfer it/them to the local directory for processing.

I know i have to use a script task to do this and i did some research and found examples for each of the above 2 steps and not both combined, so that's why I need some help here to get the logic incorporated right.

Thanks for the help in advance and i apologize for the long lines of code!

example for step 1:
----------------------------------------------------------------------------------------------------------

' Microsoft SQL Server Integration Services Script Task
' Write scripts using Microsoft Visual Basic
' The ScriptMain class is the entry point of the Script Task.

Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
Imports Microsoft.SqlServer.Dts.Runtime.Wrapper
Imports Microsoft.VisualBasic.FileIO.FileSystem
Imports System.IO.FileSystemInfo

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()

Dim cDataFileName As String
Dim cFileType As String
Dim cFileFlgVar As String
WriteVariable("SCFileFlg", False)
WriteVariable("OOFileFlg", False)
WriteVariable("INFileFlg", False)
WriteVariable("IAFileFlg", False)
WriteVariable("RCFileFlg", False)
cDataFileName = ReadVariable("DataFileName").ToString
cFileType = Left(Right(cDataFileName, 4), 2)
cFileFlgVar = cFileType.ToUpper + "FileFlg"
WriteVariable(cFileFlgVar, True)
Dts.TaskResult = Dts.Results.Success
End Sub
Private Sub WriteVariable(ByVal varName As String, ByVal varValue As Object)
Try
Dim vars As Variables
Dts.VariableDispenser.LockForWrite(varName)
Dts.VariableDispenser.GetVariables(vars)
Try
vars(varName).Value = varValue
Catch ex As Exception
Throw ex
Finally
vars.Unlock()
End Try
Catch ex As Exception
Throw ex
End Try
End Sub
Private Function ReadVariable(ByVal varName As String) As Object
Dim result As Object
Try
Dim vars As Variables
Dts.VariableDispenser.LockForRead(varName)
Dts.VariableDispenser.GetVariables(vars)
Try
result = vars(varName).Value
Catch ex As Exception
Throw ex
Finally
vars.Unlock()
End Try
Catch ex As Exception
Throw ex
End Try
Return result
End Function
End Class

example for step 2:
-------------------------------------------------------------------------------------------------------

' Microsoft SQL Server Integration Services Script Task

' Write scripts using Microsoft Visual Basic

' The ScriptMain class is the entry point of the Script Task.

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

'Create the connection to the ftp server

Dim cm As ConnectionManager = Dts.Connections.Add("FTP")

'Set the properties like username & password

cm.Properties("ServerName").SetValue(cm, "ftp.name.com")

cm.Properties("ServerUserName").SetValue(cm, "username")

cm.Properties("ServerPassword").SetValue(cm, "password")

cm.Properties("ServerPort").SetValue(cm, "21")

cm.Properties("Timeout").SetValue(cm, "0") 'The 0 setting will make it not timeout

cm.Properties("ChunkSize").SetValue(cm, "1000") '1000 kb

cm.Properties("Retries").SetValue(cm, "1")

'create the FTP object that sends the files and pass it the connection created above.

Dim ftp As FtpClientConnection = New FtpClientConnection(cm.AcquireConnection(Nothing))

'Connects to the ftp server

ftp.Connect()

'ftp.SetWorkingDirectory("..")

ftp.SetWorkingDirectory("directoryname")

Dim folderNames() As String

Dim fileNames() As String

ftp.GetListing(folderNames, fileNames)

Dim maxname As String = ""

For Each filename As String In fileNames

' whatever operation you need to do to find the correct file...

Next

Dim files(0) As String

files(0) = maxname

ftp.ReceiveFiles(files, "C: emp", True, True)

' Close the ftp connection

ftp.Close()





'Set the filename you retreive for use in data flow

Dts.Variables.Item("FILENAME").Value = maxname

Catch ex As Exception

Dts.TaskResult = Dts.Results.Failure

End Try

Dts.TaskResult = Dts.Results.Success

End Sub

End Class

View 16 Replies View Related

SQL 2012 :: FOR FILES Command To Delete Old Backup Files On Remote Server?

Feb 24, 2015

I have the need to delete old backup files via TSQL job. Found this solution online:

PushD "
emoteservershareDIFF" &&(
forfiles -m *DIFF*.sqb -d -1 -c "cmd /c del /q @path"
) & PopD

It works remotely if I run it via command prompt. But when I add this to a TSQL job on my remote SQL instance, it runs without deleting anything. What I'm missing?

View 6 Replies View Related

HELP!!! Cannot Import SSIS Package Files From .dtsx Files

Oct 8, 2007





Brief overview...Running SQL Server 2003 Server Enterprise 64 bit - All Service Packs and patches current
SQL Server 2005 Enterprise Edition 64 bit Build Microsoft SQL Server 2005 - 9.00.3054.00 (X64) Mar 23 2007 18:41:50 Copyright (c) 1988-2005 Microsoft Corporation Enterprise Edition (64-bit) on Windows NT 5.2 (Build 3790: Service Pack 2)

I cannot import any SSIS packages nor crete any new folders under stored packages. I hve googled the news groups and looked at BOL to no avail. HELP!!!!

View 20 Replies View Related

Is It A Good To Replace SQL Script Files With XML Files?

Jul 23, 2005

I am thinking about replacing the INSERT data scriptfiles that I have with XML files. This way I can open the XMLfile using an XML Editor and see the values in a GRID andmake changes easier.Do you see any problem with this approach?I managed to put together some code that is exportinga SQL table with its data to an XML file and also a codethat reads the XML file's data and inserts it into a table.Now I am researching on XSD, td:datatype, DTD...(I am new to XML) in order to figure out how I canuse a single xml file that will hold both the sql serverfields, the datatypes and their values.If you have links to some sample code that has anythingto do with the datatype export and import I am workingon, can you please share them with me?Most importantly what do you think about the idea of usingXML files vs sql scripts?Thank you

View 4 Replies View Related

Integration Services :: Converting RTF Files To PDF Files?

Jun 25, 2015

I have a scenario where I need to convert RDF files to PDF files? may I know is this achievable in SSIS - writing C# code?

View 6 Replies View Related

Transaction Log Files/Virtual Log Files

Oct 1, 2004

I am wanting to reduce the amount of Virtual Log Files I have. In reading through the Online Book Documentation, I realize that I have forgotten to move the Transaction Log Files to a different drive. Now that the server is in production, I wanted to get some input about the best way of making this change.

Can I just change the directory the log files are being written to in the DB properties without having any adverse problems occurring?

View 2 Replies View Related

Empty Log Files And Data Files

Sep 17, 2004

Hi!
I'm using replication with two database on SQL 2000,when begin, the log files size is 50mb and the data files size is 150mb. But now the log files size is 2Gb and the data files size is 4Gb. I would like to decrease the log files and the data files ??? How do i do this???
(I using Truncate and shrink doesn't change )
Thanks!!!

View 2 Replies View Related

Process Many Image Files And Wav Files

Dec 11, 2005

I need to write codes to access many image files and wave files and display them on the webpage. Both of these files are stored on the server (as many experts in this forum adviced) and their locations are in the SQL server database. About the wav files, I think I will have to convert them to MP3 first for fast delivery on internet. Since I am a newbie, any help would be appreciated.
Thanks,

View 14 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved