T-SQL
1 2 3 4 5 6 7 8 9 10 |
/* Replace procedure name and parameter with your own */ CREATE PROCEDURE spAlbumsFromArtist @ArtistName varchar(255) AS /* Replace everything below with your own code */ SELECT AlbumName, ReleaseDate FROM Albums INNER JOIN Artists ON Albums.ArtistId = Artists.ArtistId WHERE Artists.ArtistName = @ArtistName; |
PowerShell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
Import-Module Adaxes $csvFilePath = "\\Server\Share\example.csv" # TODO: modify me function ExecuteOperation ($username, $operationType) { switch ($operationType) {- "Delete" { # Try to delete the user try { Remove-AdmUser -Identity $userName -AdaxesService localhost -ErrorAction Stop -Confirm:$False } catch { return "Error: User '$userName' was not deleted. Error message: " + $_.Exception.Message }- return "User '$userName' deleted successfully." } "Disable" { # Try to disable the User try { Disable-AdmAccount -Identity $userName -AdaxesService localhost -ErrorAction Stop } catch { return "Error: User '$userName' was not disabled. Error message: " + $_.Exception.Message } return "User '$userName' disabled successfully." } default { return "Unknown operation: " + $operationType + " for user: " + $user.username } } } # Check file path if (!(Test-Path -Path $csvFilePath)) { Write-Host "File '$csvFilePath' was not found." return } # Import data $csvFile = Import-Csv -Path $csvFilePath foreach ($user in $csvFile) { $result = ExecuteOperation $user.Name $user.Operation Write-Host $result } |
Batch
1 2 3 4 |
CREATE PROCEDURE GetCustInfo (@CustomerID INT) AS SELECT * FROM Customers WHERE CustID = @CustomerID SELECT OrderID FROM Orders WHERE CustID = @CustomerID AND Status = 'OPEN' |
VB.Net
1 2 3 4 5 6 7 8 9 |
Imports System Imports System.Windows.Forms Module Module1 Sub Main() Console.WriteLine("Hello World! (VB)") MessageBox.Show("Hello World! (VB)") End Sub End Module |
C#
1 2 3 4 5 6 7 8 9 10 11 12 13 |
// create date time 2008-03-09 16:05:07.123 DateTime dt = new DateTime(2008, 3, 9, 16, 5, 7, 123); String.Format("{0:y yy yyy yyyy}", dt); // "8 08 008 2008" year String.Format("{0:M MM MMM MMMM}", dt); // "3 03 Mar March" month String.Format("{0:d dd ddd dddd}", dt); // "9 09 Sun Sunday" day String.Format("{0:h hh H HH}", dt); // "4 04 16 16" hour 12/24 String.Format("{0:m mm}", dt); // "5 05" minute String.Format("{0:s ss}", dt); // "7 07" second String.Format("{0:f ff fff ffff}", dt); // "1 12 123 1230" sec.fraction String.Format("{0:F FF FFF FFFF}", dt); // "1 12 123 123" without zeroes String.Format("{0:t tt}", dt); // "P PM" A.M. or P.M. String.Format("{0:z zz zzz}", dt); // "-6 -06 -06:00" time zone |
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
from datetime import datetime now = datetime.now() mm = str(now.month) dd = str(now.day) yyyy = str(now.year) hour = str(now.hour) mi = str(now.minute) ss = str(now.second) print mm + "/" + dd + "/" + yyyy + " " + hour + ":" + mi + ":" + ss |
R
1 2 3 4 5 6 7 |
readinteger <- function() { n <- readline(prompt="Enter an integer: ") return(as.integer(n)) } print(readinteger()) |
Latest posts by SQLShack (see all)
- Best author award in 2021 - January 3, 2022
- Best author award in 2020 - January 5, 2021
- Best author award in 2019 - January 3, 2020