Skip to content

Instantly share code, notes, and snippets.

@ateneva
ateneva / SQL_position_vs_strpos.sql
Last active Sep 2, 2018
What is the difference between position() and strpos() in PostgreSQL?
View SQL_position_vs_strpos.sql
-------------------------------PostgreSQL-----------------------------------------
select
tags,
position('technology' in tags) as position_tech,
strpos(tags, 'technology') as strpos_tech
position('Technology' in tags) as position_Tech,
strpos(tags, 'Technology') as strpos_Tech,
@ateneva
ateneva / SQL_instr_vs_locate.sql
Last active Sep 2, 2018
What is the difference between instr() and locate() in MySQL?
View SQL_instr_vs_locate.sql
/* MySQL */
select
tags,
instr(tags, 'TED'),
locate('TED', tags),
locate('TED', tags, 5),
instr(tags, 'ted'),
locate('ted', tags),
@ateneva
ateneva / SQL_charindex_vs_patindex.sql
Last active Sep 2, 2018
What is the difference between charindex and patindex in SQL Server?
View SQL_charindex_vs_patindex.sql
-------------------SQL Server-------------------------------------------
select
tags,
charindex('technology', tags) as char_position_tech,
patindex('technology', tags) as pat_position_tech,
patindex('%technology%', tags) as pat_position_tech_2,
charindex('Technology', tags) as char_position_Tech,
@ateneva
ateneva / SQL_upper_lower.sql
Last active Aug 26, 2018
How do I change the case of a string?
View SQL_upper_lower.sql
---------------------SQL Server----------------------------------------------------------------
select
title,
lower(title) as lowercase_string,
upper(title) as uppercase_string
from datageeking.dbo.films
@ateneva
ateneva / SQL_string_functions_proper_equivalent.sql
Last active Aug 18, 2018
How do I capitalize each word in a string with SQL?
View SQL_string_functions_proper_equivalent.sql
--***********************************************************************************************************************
------------------------SQL Server-------------------------------------------------------------------------------------
----1) Get the first letter of the string & capitalize it
upper(left(ltrim(title),1)) as first_letter_first_word,
----2) Get the remaining string
right(lower(ltrim(title)), len(lower(ltrim(title)))-1) as remaining_string,
----3) Find the position of the first blank space-----------------
@ateneva
ateneva / ForEachS_Display_SlideIDs.bas
Last active Aug 2, 2018
How do I show the slide IDs of multiple slides?
View ForEachS_Display_SlideIDs.bas
Sub Display_SlideIDs()
Dim i As Integer
Dim PPS As Slide
Dim p As Presentation
Set p = ActivePresentation
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
For Each PPS In p.Slides
@ateneva
ateneva / ForEachS_ShowSlideID.bas
Created Aug 2, 2018
How do I show the Slide ID of a single slide?
View ForEachS_ShowSlideID.bas
Sub ShowSlideID()
Dim p As Presentation
Set p = ActivePresentation
Dim No As Integer
Dim i As Integer
'***************************
i = InputBox("Enter Slide number")
View ForEachShOnSlide_Count_shapes_on_slide.bas
Sub Count_shapes_on_slide()
Dim p As Presentation
Set p = ActivePresentation
Dim No As Integer
Dim i As Integer
Dim PPS As Slide
Dim Sh As Shape
'***************************
@ateneva
ateneva / ForEachShOnSlide_Delete_shape_type.bas
Created Aug 2, 2018
How do I remove certain shape types from a slide with VBA?
View ForEachShOnSlide_Delete_shape_type.bas
Sub Delete_shape_type()
Dim p As Presentation
Set p = ActivePresentation
Dim PPS As Slide
Dim Sh As Shape
'***************************
For Each PPS In p.Slides
@ateneva
ateneva / ForEachShOnSlide_Delete_All_but_Title.bas
Created Aug 2, 2018
How do I delete all of a slide content but its title with VBA?
View ForEachShOnSlide_Delete_All_but_Title.bas
Sub Delete_All_but_Title()
Dim p As Presentation
Set p = ActivePresentation
Dim PPS As Slide
'***************************
For Each PPS In p.Slides
Dim i As Shape
You can’t perform that action at this time.