T-SQL

What is the difference between Stored Procedures and User Defined Functions?

What is the difference between Stored Procedures and User Defined Functions in sqlserver.

Set two variables using a Select query in a stored procedure.

SET @Password = ( 
    SELECT Value1,Value2
    FROM [dbo].[Table1]  
    WHERE [Expr1]) 

I am trying to get both values 'Value1' and 'Value2' in two variables to be used in same SP in next query. Is it possible or do I have to write two queries for this. Is it there a concept of arrays in sql server

SQL Server: Backup and Restore Database using T-SQL

Its very easy to take Backup and Restore your Database using T-SQL even if you are not a DBA. In one of the client application, I wanted to take periodic Backup without logging in to SQL Server Management Studio. Here in this small tutorial I will try to elaborate the procedure of taking database backup using T-SQL.

1. Create a Database

CREATE DATABASE PracticeDB

2. Take Backup of the Database

BACKUP DATABASE PracticeDB
TO DISK='C:\PracticeD.bak'
WITH DESCRIPTION='Database Backup',
INIT,
PASSWORD='TryAgain'

Syndicate content