You can backup a database using the following command:
BACKUP DATABASE YourDatabaseName TO DISK = 'C:\Backup\YourDatabaseName.bak';
This command creates a backup of the YourDatabaseName
database to the specified location.
Every Question..What does it mean? Why is this? How it works?
Microsoft .Net (pronounced dot (.) net) may be a package element that runs on the Windows software package.
.Net provides tools and libraries that change developers to form Windows package a lot of quicker and easier.
Microsoft describes it as:".Net is that the Microsoft internet Service strategy to attach data, people,
system and devices through software".I'm Choulla Naresh..!
You can backup a database using the following command:
BACKUP DATABASE YourDatabaseName TO DISK = 'C:\Backup\YourDatabaseName.bak';
This command creates a backup of the YourDatabaseName
database to the specified location.
To enable the execution plan for a query, run:
SET SHOWPLAN_ALL ON;
Then run your query. The execution plan will be displayed as part of the result. To turn off the execution plan, use:
SET SHOWPLAN_ALL OFF;
You can use the following query to find the largest tables by data size:
SELECT t.NAME AS TableName, p.rows AS RowCounts, SUM(a.total_pages) * 8 AS TotalSpaceKB, SUM(a.used_pages) * 8 AS UsedSpaceKB, (SUM(a.total_pages) - SUM(a.used_pages)) * 8 AS UnusedSpaceKB FROM sys.tables t INNER JOIN sys.indexes i ON t.OBJECT_ID = i.object_id INNER JOIN sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id INNER JOIN sys.allocation_units a ON p.partition_id = a.container_id WHERE t.NAME NOT LIKE 'dt%' AND i.OBJECT_ID > 255 GROUP BY t.Name, p.Rows ORDER BY TotalSpaceKB DESC;
This query returns the largest tables by row count and space usage.
You can get the list of all users in a database using this query:
SELECT name AS Username FROM sys.database_principals WHERE type IN ('S', 'U') -- 'S' for SQL user, 'U' for Windows user AND name NOT LIKE '##%'; -- Exclude system users
This lists all users in the current database.
Use the following query to find currently running queries:
SELECT r.session_id, r.start_time, s.text AS query_text, r.status, r.command, r.total_elapsed_time FROM sys.dm_exec_requests r CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) s;
This returns details about all currently running queries, including the session ID, query text, and execution status.
You can check the status of running transactions using this query:
SELECT session_id, transaction_id, database_id, transaction_begin_time, transaction_state, transaction_status
FROM sys.dm_tran_active_transactions;
You can use the following query to list all tables in the current database:
SELECT TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_CATALOG = 'YourDatabaseName';
This query returns the names of all base tables in the specified database.
You can check the size of a database using the following query:
EXEC sp_spaceused;
Or, for a specific database:
USE YourDatabaseName;
EXEC sp_spaceused;
SELECT
es.session_id AS SPID,
es.login_name,
es.status,
es.host_name,
es.program_name,
es.database_id,
DB_NAME(es.database_id) AS database_name,
ec.client_net_address,
er.wait_type,
er.wait_time,
er.blocking_session_id
FROM sys.dm_exec_sessions es
LEFT JOIN sys.dm_exec_connections ec ON es.session_id = ec.session_id
LEFT JOIN sys.dm_exec_requests er ON es.session_id = er.session_id
WHERE es.database_id = DB_ID('YourDatabaseName');
------------------------------------------------------------------------------------
kill SSID
If you are getting this error breakpoint in view then there is some error in view or some property name is wrong. Then check and fix all lines. After correction it will work.