Search the Blog

Friday, May 6, 2022

SQL Important Scripts

 To create a new table and load the data directly


select  Param1

      ,Param2

      ,Param3

      ,Param4

      ,Param5

      ,Param6

      ,Param7

INTO New_Table_Name   FROM

 OLD_TABLE_NAME where month(created_on)=4


Monday, April 25, 2022

SQL SERVER database TYPES

 

SYSTEM_DATABASESAll system databases (master, msdb, and model)
USER_DATABASESAll user databases
ALL_DATABASESAll databases
AVAILABILITY_GROUP_DATABASESAll databases in availability groups
USER_DATABASES, -AVAILABILITY_GROUP_DATABASESAll user databases that are not in availability groups
Db1The database Db1
Db1, Db2The databases Db1 and Db2
USER_DATABASES, -Db1All user databases, except Db1
%Db%All databases that have “Db” in the name
%Db%, -Db1All databases that have “Db” in the name, except Db1
ALL_DATABASES, -%Db%All databases that do not have “Db” in the name

SQL SERVER BACKUP SCRIPT ON LINUX

 BACKUP DATABASE [DMT] TO  

DISK = N'/var/opt/mssql/data/DMT.bak' 

WITH NOFORMAT, NOINIT,  NAME = N'DMT-

Full Database Backup', 

SKIP, NOREWIND, 

NOUNLOAD,  

STATS = 10

GO


Translate