Below query will return the total number of tables in sql server
Below query will return the total number of views in sql server
Below query will return the total number of stored procedures in sql server
Below query will return the total number of functions in sql server
If you want to get the names of all tables, views, stored procedures or functions then use the below queries
When you truncate the table data, table Identity will be reset automatically. But when you delete the records in the table Identity will not be reset.
Below query will reset the table Identity in SQL server.
Below are the differences between Truncate and Delete in MS-SQL.
This example shows you how to restore SQL database from a backup file using SQL Query.
In the above example SampleDB is the database name. N'E:\DB\Bakup\SampleDBBackupfile.bak' physical path of backup file.
There are multiple ways to check the given date is weekend or not. Sql function DATENAME returns the given date name as Sunday, Monday, Tuesday, ... We can compare the return value with Saturday and Sunday and can determine the given date is weekend or not.Sql function DATEPART returns the given date number 1 to 7. Where 1-Sunday, 2-Monday, ... 7-Saturday. If the return value is 1 or 7 then the given date is weekend otherwise given date is weekday.
The below query will return the file name from file full path in SQL Server.
Output -> EmployeeFeed.xlsx
Below query will give you the last day of the previous month.
Below query will give you the last day of the current month.
Below query will give you the last day of the next month.
The below query will pad leading zeros to number (integer).
ExampleThe below example will add padding zeros upto 4 digits.
Below query will fetch the list of stored procedure names that uses the given specific text.
When we restore the database in SQL server, sometimes we may face problem in login with the existing login credentials in restored database. to fix the issue just run the below query by replacing the 'uname' with your login username.
Below SQL query will fixes the login problem for user 'uname' .