Showing posts with label #SQLServer. Show all posts
Showing posts with label #SQLServer. Show all posts

Tuesday, 25 June 2024

How to backup SQL Server database using command prompt ?

In this video, I have explained how to backup SQL Server database using Command Prompt. 

Steps:-

1) Open command prompt.

2) Type following command in command prompt.

3) Hit enter.

SqlCmd -S BOSS-PC\SQLEXPRESS -U sa -P 1234 -Q "Backup Database MyDb_18122018 Το Disk='D:\Backup\MyDb_18122018.bak"

SqlCmd - It will use SQL server command tool.

-S BOSS-PC\SQLEXPRESS(It's SQL server name.)

-U sa (SQL server username)

-P 1234(SQL server password.)

-Q "Backup Database- It's SQL command MyDb_18122018(My database name.)

To Disk='D:\Backup\MyDb_18122018.bak" (Destination for storing database backup.)

Watch my YouTube video on same topic:- 


Monday, 24 June 2024

How to configure and send email using SQL server ?

 In this video, I have explained how to configure and send email using SQL Server.  

Steps:-

1) Unblock SQL server to send email.

USE MASTER

GO

SP_CONFIGURE 'show advanced options', 1

RECONFIGURE WITH OVERRIDE

GO

SP_CONFIGURE 'Database Mail XPs', 1

RECONFIGURE WITH OVERRIDE

GO

SP_CONFIGURE 'show advanced options', o

RECONFIGURE WITH OVERRIDE

GO

2)Add mail account to SQL Server.

EXEC msdb.dbo.sysmail_add_account_sp

@account_name = 'xyz_Mail_Account'

, @description = 'Send mails through SQL Server'

, @email_address = 'Your Email ID'

, @display_name = 'xyz'

, @replyto_address = 'Your Email ID'

, @mailserver_name = 'Host Name'

, @username = 'Your Email ID'

, @password = 'Account Password'

, @port = 587

, @enable_ssl = 1

GO


3) Create User account Profile using inbuilt stored procedure

EXEC msdb.dbo.sysmail_add_profile_sp 
    @profile_name = 'xyz_Email_Profile', 
    @description = 'Send emails using SQL Server'
    GO

4)Add User account to Profile using inbuilt stored procedure

EXEC msdb.dbo.sysmail_add_profileaccount_sp 
    @profile_name = 'xyz_Email_Profile',
    @account_name = 'xyz_Mail_Account',
    @sequence_number = 1
    GO

5) Send email using inbuilt stored procedure
EXEC msdb.dbo.sp_send_dbmail 
    @profile_name = ' xyz_Email_Profile', 
    @recipients = 'Recipient Email ID', 
    @subject = 'Email from SQL Server', 
    @body = 'This is my test email.', 
    @importance = 'HIGH'
    GO


        Detail explanation is available in below video


Saturday, 22 June 2024

Different Types Of Clauses In SQL Server

 
In this video, I have explained different types of clauses in SQL server. This video is helpful for beginners to learn SQL Server concept. 

  • Clauses are used with queries to find out exact data from table.
  • Clauses can be used with all join types

    Following are types of Clauses:-
  1. Where Clause
  2. Order By Clause
  3. Group By Clause
  4. Having Clause