Posts

SQL Query

SELECT fname , job_id , pub_id , convert ( varchar , hire_date ) FROM dbo . employee ; SELECT fname , job_id , pub_id , convert ( varchar , hire_date , 101 ) FROM dbo . employee ; SELECT fname , job_id , pub_id , convert ( varchar , hire_date , 102 ) FROM dbo . employee ; SELECT fname , job_id , pub_id , convert ( varchar , hire_date , 103 ) FROM dbo . employee ; SELECT fname , job_id , pub_id , convert ( varchar , hire_date , 104 ) FROM dbo . employee ; Function count n   Return sigle value use pubs ; -- Count Total number select COUNT (*) As 'Total' from employee ; Use where use pubs ; -- Count Total number select COUNT (*)   from dbo . jobs where min_lvl = '25' ;   AVG function use pubs ; -- AVG < number select * from   dbo . sales Where qty < ( select Avg ( qty ) from sales ); Minimum function use pubs ; -- min number select MIN ( qty ) from   dbo . sales ; Max FUNCTION use p...

Create Database SQL Server backup Script

Image
  To generate a SQL Server backup script that includes data, you can use the SQL Server Management Studio (SSMS) Generate Scripts wizard. Here are the steps to do so: Open SSMS and connect to the SQL Server instance you want to backup. Right-click on the database you want to backup and select "Tasks" -> "Generate Scripts". In the "Introduction" page of the wizard, click "Next". In the "Choose Objects" page, select "Select specific database objects" and select the tables you want to include in the backup. Click "Next". In the "Set Scripting Options" page, set the following options: "Script Data" to "True" "Types of data to script" to "Data only" "Script Drop and Create" to "False" "Script for Server Version" to the appropriate version of SQL Server you want to run the script on Click "Next" to review the summary of your settin...