Wildcard Characters in SQL Server
Wildcard Characters in SQL Server
| Symbol | Description | Example |
|---|---|---|
| % | Represents zero or more characters | bl% finds bl, black, blue, and blob |
| _ | Represents a single character | h_t finds hot, hat, and hit |
| [] | Represents any single character within the brackets | h[oa]t finds hot and hat, but not hit |
| ^ | Represents any character not in the brackets | h[^oa]t finds hit, but not hot and hat |
| - | Represents a range of characters | c[a-b]t finds cat and cbt |
Here are some examples showing different LIKE operators with '%' and '_' wildcards:
| LIKE Operator | Description |
|---|---|
| WHERE CustomerName LIKE 'a%' | Finds any values that starts with "a" |
| WHERE CustomerName LIKE '%a' | Finds any values that ends with "a" |
| WHERE CustomerName LIKE '%or%' | Finds any values that have "or" in any position |
| WHERE CustomerName LIKE '_r%' | Finds any values that have "r" in the second position |
| WHERE CustomerName LIKE 'a__%' | Finds any values that starts with "a" and are at least 3 characters in length |
| WHERE ContactName LIKE 'a%o' | Finds any values that starts with "a" and ends with "o" |
select name from sys.servers -- > Lists the linked server
Lists the linked server
select name from sys.servers -- > Lists the linked server
How to View SQL Server Database Size and File Locations
How to View SQL Server Database Size and File Locations
SELECT
--database ID
mdf.database_id,
--database name
mdf.name,
--database file location
mdf.physical_name as data_file,
ldf.physical_name as log_file,
db_size_MB = CAST((mdf.size * 8.0)/1024 AS DECIMAL(8,2)),
log_size = CAST((ldf.size * 8.0 / 1024) AS DECIMAL(8,2))
FROM (SELECT * FROM sys.master_files WHERE type_desc = 'ROWS' ) mdf
JOIN (SELECT * FROM sys.master_files WHERE type_desc = 'LOG' ) ldf
ON mdf.database_id = ldf.database_id
--sort DESC or ASC
order by db_size_MB DESC
change default kernel version RHEL/CentOS 8
change default kernel version RHEL/CentOS 8
List installed kernel versions
[root@b1s ~]# rpm -qa | grep kernel | sort
kernel-4.18.0-193.28.1.el8_2.x86_64
kernel-4.18.0-240.10.1.el8_3.x86_64
kernel-4.18.0-240.1.1.el8_3.x86_64
kernel-core-4.18.0-193.28.1.el8_2.x86_64
kernel-core-4.18.0-240.10.1.el8_3.x86_64
kernel-core-4.18.0-240.1.1.el8_3.x86_64
kernel-devel-4.18.0-193.28.1.el8_2.x86_64
kernel-devel-4.18.0-240.10.1.el8_3.x86_64
kernel-devel-4.18.0-240.1.1.el8_3.x86_64
kernel-headers-4.18.0-240.10.1.el8_3.x86_64
kernel-modules-4.18.0-193.28.1.el8_2.x86_64
kernel-modules-4.18.0-240.10.1.el8_3.x86_64
kernel-modules-4.18.0-240.1.1.el8_3.x86_64
kernel-tools-4.18.0-240.10.1.el8_3.x86_64
kernel-tools-libs-4.18.0-240.10.1.el8_3.x86_64
[root@b1s ~]# grubby --info=ALL | grep ^kernel
kernel="/boot/vmlinuz-4.18.0-240.10.1.el8_3.x86_64"
kernel="/boot/vmlinuz-4.18.0-240.1.1.el8_3.x86_64"
kernel="/boot/vmlinuz-4.18.0-193.28.1.el8_2.x86_64"
kernel="/boot/vmlinuz-0-rescue-7919fe4e4b09483bab8b9140dcd8a82e"
To check the currently active kernel version we will useunamewith-rwhich will give us kernel release information:
[root@b1s ~]# uname -r
4.18.0-193.28.1.el8_2.x86_64
[root@b1s ~]# grubby --info="/boot/vmlinuz-4.18.0-193.28.1.el8_2.x86_64"
index=2
kernel="/boot/vmlinuz-4.18.0-193.28.1.el8_2.x86_64"
args="ro crashkernel=auto resume=/dev/mapper/cl_b1s-swap rd.lvm.lv=cl_b1s/root rd.lvm.lv=cl_b1s/swap rhgb quiet amd_iommu=on $tuned_params"
root="/dev/mapper/cl_b1s-root"
initrd="/boot/initramfs-4.18.0-193.28.1.el8_2.x86_64.img $tuned_initrd"
title="CentOS Linux (4.18.0-193.28.1.el8_2.x86_64) 8 (Core)"
id="7919fe4e4b09483bab8b9140dcd8a82e-4.18.0-193.28.1.el8_2.x86_64"
Check the kernel version which is going to be activated post reboot
[root@b1s ~]# grubby --grub2 --default-title
CentOS Linux (4.18.0-193.28.1.el8_2.x86_64) 8 (Core)
[root@b1s ~]# grubby --default-kernel
/boot/vmlinuz-4.18.0-193.28.1.el8_2.x86_64
# grubby --default-index 0
Change the default kernel
[root@b1s ~]# grubby --set-default "/boot/vmlinuz-4.18.0-193.14.3.el8_2.x86_64"
Verify the new default kernel
# grubby --default-kernel
# grubby --default-index
# uname -r




