Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 5 years ago.
Improve this question
How can i fix the page level corruption in sql database. I am facing a big issue related to this. Can anyone help me.
Go to SQL Server Management Studio
Select the DB
Right Click the DB
Go to Properties
Select Options
Under Other Option select the Page Verify
Select as NONE.
Run this Query to Change DB into Single User Mode
ALTER DATABASE corrupted_db SET SINGLE_USER WITH ROLLBACK IMMEDIATE
Run this Query to Recover the Table/DB.
DBCC CheckTable ('corrupted_table', REPAIR_ALLOW_DATA_LOSS)
(OR)
DBCC CheckDB ('corrupted_db', REPAIR_ALLOW_DATA_LOSS)
Once this Execution Completed Sql returns “Errors are Corrected”
Run this Query to Change the DB into Multi-User Mode
ALTER DATABASE Application Manager SET MULTI_USER
Go to SQL Server Management Studio
Select the DB
Right Click the DB
Go to Properties
Select Options
Under Other Option select the Page Verify
Select the Option CHECKSUM.
Now Run DBCC CHECKDB('Your DB')
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 days ago.
The community is reviewing whether to reopen this question as of 3 days ago.
Improve this question
I have a stored procedure stored in a Serverless Pool SQL DB
(https://i.stack.imgur.com/wSppv.png)
In Synapse Pipelines I' no able to use the SQL Pool Stored Procedure activity because is only for a Dedicated Pool so I'm using the Stored Procedure Activity
(https://i.stack.imgur.com/zlBLJ.png)
When triggered the corresponding pipeline nothing happens
(https://i.stack.imgur.com/rmHLR.png)
I was investigating any restriction on using the Stored Procedure Activity and nothing. I do not want to use the Script Activity but if there's no other chance I'll be forced to do that.
A sample of the script is
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE OR ALTER PROCEDURE CSVtoParquetBronze
AS
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[bronze].[Table]') AND type in (N'U'))
DROP EXTERNAL TABLE bronze.Table;
GO
CREATE EXTERNAL TABLE bronze.Account
WITH
(
LOCATION = 'bronze/Table',
DATA_SOURCE = lakehouse_EDS,
FILE_FORMAT = SynapseParquetFormat
)
AS
SELECT *
FROM dbo.Table
GO
GO
The expecting result its simple since the connection is working fine and the Stored Procedure exists in the Database as well as the location, data source y file format.
(https://i.stack.imgur.com/5d1f4.png)
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I am simulating a database corruption for my own practice.
What I did was editing the .LDF file and messing it up and when I run SQL server, the database is in "Recovery Pending" mode, meaning it has been corrupted.
Without any backup to be restored or without replacing the backup .LDF file, is there any way I could recover my database?
Note: I am not interested in using any third party tools/software.
Would appreciate any suggestion.
Try to use these commands on the master database. It will reset the state of the database so you can work with it. This will put it into SINGLE USER MODE and ROLLBACK pending changes. After repair it will allow MULTIUSER AGAIN.
EXEC sp_resetstatus 'yourDBname';
ALTER DATABASE yourDBname SET EMERGENCY
DBCC checkdb('yourDBname')
ALTER DATABASE yourDBname SET SINGLE_USER WITH ROLLBACK IMMEDIATE
DBCC CheckDB ('yourDBname', REPAIR_ALLOW_DATA_LOSS)
ALTER DATABASE yourDBname SET MULTI_USER
You can also bring the database back online without the .ldf file (as its corrupted or even without having the .ldf file at all).
Based on your question I am assuming that you had a clead DB shutdown before you have corrupted the log (if not there is another way, just drop an update request in comment if needed). To check that just run:
SELECT [name], [state_desc], [is_cleanly_shutdown] FROM sys.databases;
Then if [is_cleanly_shutdown] = 1 and you had just a single log file for your database (mostly this is the case):
CREATE DATABASE [Your_DB_Name] ON
(FILENAME = N'D:\full_file_path\db.mdf')
FOR ATTACH;
If you had multiple log files then run:
CREATE DATABASE [DB_Name] ON
(FILENAME = N'D:\full_file_path\db.mdf')
FOR ATTACH_REBUILD_LOG;
In both scenarios you will create a new log file (just single log file) which will be just 0.5MB is size so you have to modify it for your needs:
ALTER DATABASE [Your_DB_Name] MODIFY FILE
(
NAME = N'DB_Name_log'
,SIZE = 100 {KB | MB | GB | TB | UNLIMITED }
,FILEGROWTH = 20 {KB | MB | GB | TB | % })
);
Update:
As stated here
You need a third-party tool to do this. The SQL recovery tool recovers Tables, Keys, Indexes, Views, Triggers, Stored Procedures, Rules, User Defined Functions, and more. In addition, the MS SQL database recovery tool supports recovery of XML indexes and data types, column set property, sparse columns, and file stream data types.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
We had created a trigger for inserting a set of rows.
I want to schedule this trigger automatically and insert these data into another table. i.e, it has to execute automatically based on the period given.
Kindly suggest the possibilities steps for this.
Here i give you the clear explanation about the operation,
My project to transfer the data from MS SQL database table to MY SQL Database table. This event has to be scheduled. I have to select few fields from MS Sql table and that selected data to be transfer to My Sql table Automatically based on Scheduled.
You could use mysql event scheduler to configure and run your job.
Please have look into
http://dev.mysql.com/doc/refman/5.1/en/events-configuration.html
First, Trigger is one database object and trigger created over the any physical table. this is depends on table action so at every action of table trigger will execute.
we cant schedule trigger to execute on perticluar time.
There is alternative solution is: Enable and Disable trigger using scedule SQL Job.
Script is :
--To Enalble Trigger
ENABLE TRIGGER [Trigger_Name] ON [TableName]
GO
--To Disable Trigger
DISABLE TRIGGER [Trigger_Name] ON [TableName]
GO
If you're using MS SQL, then you can use SQL Server Agent to schedule a job/task to execute whatever you need done.
You can read more about it here http://msdn.microsoft.com/en-us/library/ms191439.aspx
Your best bet maybe to create a stored procedure and then in the scheduled job, simply execute that stored procedure to run.
Alternatively, if you don't have SQL Server Agent (requires full version of MS SQL not SQL Server Express) then you could possibly look into using Windows Scheduled Task to schedule a batch file to run periodically, making a call to the sqlcmd utility http://technet.microsoft.com/en-us/library/ms165702(v=sql.105).aspx which you should be able to setup to execute your stored procedure.
Hope this helps.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
When I need more information about table and its column I always use the build-in stored procedure 'sp_help xxxxx' to retrieve more information.
What other method or SP are usable to use?
You can use sp_depends to get want tables and columns it is using
EXEC sp_depends yourProcedure;
I prefer to use dynamic management views (DMV) and functions (DMF) to get more information about database server..........The DMV/DMF's have been organized into the following different groups:
Common Language Runtime related
Database Mirroring related
Execution related
Full-Text Search related
Index related
I/O related
Query Notifications related
Replication related
Service Broker related
SQL Server Operation system
Transaction related
Just browsing to the table in SQL Server Management Studio will tell you quite a lot.
Table/Column definitions.
Indexes
Triggers
Constraints
Primary/Foreign Keys
Dependancies
etc, etc
Look into the sysobjects view (http://msdn.microsoft.com/en-us/library/ms177596.aspx):
SELECT * FROM sysobjects WHERE type = 'P'
Other sys view can be handy too.
How about using sp_columns
EXEC sp_columns #table_name = N'TableName'
Using sp_helptext will come in handy, it gives you the definition of a stored procedure, function or view.
I.E.:
CREATE PROC usp_MyProcedure AS SELECT * FROM TABLE
Runing the following will output the query above.
Exec sp_helptext 'usp_MyProcedure'
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have been working on a database for a couple of weeks now, and suddenly nothing works and I just can't figure out how to solve it.
I can login to SQL server and list all the tables and sprocs. The problem is that when I try to run a sproc I get a message telling me that there are no such table, even though it exists.
When I try to alter or create a sproc I get the following message:
Msg 262, Level 14, State 1, Procedure usp_GetUser, Line 14
CREATE PROCEDURE permission denied in database 'master'.
What can be wrong?
... in database 'master'.
Wrong database context: I assume it should be "MyDatabase" not "master"
You're currently running against the master database rather than whichever user database you have been working on.
Either run
use MyDatabaseName
Or at the top of SSMS there is a drop down that currently says ''master". Change it to your database name