## Syntax ```mermaid %%{init: { 'theme': 'base', 'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' }, 'themeVariables': { 'fontSize': '11px', 'fontFamily': 'Arial' } }}%% flowchart LR Start((START)) --> BASENAME[BASENAME]:::quoted BASENAME --> FUNCPARS1["("]:::quoted FUNCPARS1 --> FUNCPARS2[parameters] FUNCPARS2 --> FUNCPARS3[")"]:::quoted FUNCPARS3 --> End((END)) ``` ## Purpose The `BASENAME` SQL function extracts the file name from a file path. Parameters: - File path: Full path of a file, containing filename, but also possibly drive, folders and extension. - Extension: Optional extension to remove, including leading '.' when necessary. Returns: the file name from the file path. ## Examples The following example extracts the filename from a file name and path: ```sql select basename('c:\temp\myfile.png') -------------------- myfile.png ``` The following example extracts the filename from a file name and path, including removal of the `.png` extension: ```sql select basename('c:\temp\myfile.png', '.png') -------------------- myfile ```