ms-sql-server-connection-source-codes GitHub Details, Stars and Alternatives | OpenRepoFinder
petrfaltus / repository
ms-sql-server-connection-source-codes
Console applications for connection to the Microsoft SQL Server, how to update rows, how to read the table and how to call the stored function and the stored procedure. Complete example collection including Docker and SQL init. Code for Java built by the Maven, for Java built by the Gradle, for C# built by the .NET Framework and for PHP.
A transparent discovery signal based on current public GitHub metadata.
Recent activity35% weight
10
Community adoption25% weight
0
Maintenance state20% weight
100
License clarity10% weight
0
Project information10% weight
75
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
README preview
Microsoft SQL Server connection source codes
Small example console source codes how to connect to the Microsoft SQL Server, how to update rows and how to read the table.
Running under Windows
clone this repository to your computer
install the Microsoft SQL Server (as a Docker container)
prepare the user, the table and rows in the database
Console applications for a network TCP and UDP socket communication over IPv4 and IPv6. Senders and receivers, complete example collection. Code for Java, for C# built by the .NET Framework, for PHP and for Python.
Console applications for connection to the Oracle database, how to update rows, how to read the table and how to call the stored function and the stored procedure. Complete example collection including Docker and SQL init. Code for Java built by the Maven, for Java built by the Gradle, for C# built by the .NET Framework and for PHP.
Use prepared Windows batches, every SQL command terminate by the keyword GO
SELECT @@version;
GO
Connection using Microsoft SQL Server Management Studio
User sa (default password Syst3mAdm1n!)
User testuser (default password T3stUs3r!)
SQL lines for sa
CREATE DATABASE testdb;
USE testdb;
CREATE LOGIN testuser WITH PASSWORD = 'T3stUs3r!';
CREATE USER testuser FOR LOGIN testuser;
GRANT SELECT TO testuser;
GRANT CREATE TABLE TO testuser;
GRANT INSERT TO testuser;
GRANT UPDATE TO testuser;
GRANT ALTER TO testuser;
GRANT EXECUTE TO testuser;
ALTER LOGIN testuser WITH DEFAULT_DATABASE=testdb;
SQL lines for testuser
USE testdb;
CREATE TABLE animals (
name VARCHAR(40) NOT NULL,
legs TINYINT NOT NULL,
created DATETIME DEFAULT GETDATE(),
updated DATETIME,
remark VARCHAR(80),
id INT IDENTITY(1,1) PRIMARY KEY NOT NULL
);
CREATE TRIGGER animals_update
ON animals
AFTER UPDATE
AS
BEGIN
SET NOCOUNT ON;
UPDATE animals
SET updated = GETDATE()
WHERE id IN (SELECT id FROM Inserted)
END;
INSERT INTO animals (name, legs) VALUES ('chicken', 2);
INSERT INTO animals (name, legs) VALUES ('fox', 4);
INSERT INTO animals (name, legs) VALUES ('eagle', 2);
INSERT INTO animals (name, legs) VALUES ('ant', 6);
INSERT INTO animals (name, legs) VALUES ('horse', 4);
CREATE OR ALTER FUNCTION factorial(@n INT) RETURNS INT AS
BEGIN
IF (@n < 0)
RETURN -1;
DECLARE @result INT = 1;
IF (@n < 2)
RETURN @result;
DECLARE @ijk INT = 2;
WHILE @ijk <= @n
BEGIN
SET @result = @result * @ijk;
SET @ijk = @ijk + 1;
END;
RETURN @result;
END;
CREATE OR ALTER PROCEDURE add_and_subtract(@a INT, @b INT, @x INT OUT, @y INT OUT) AS
BEGIN
SET @x = @a + @b;
SET @y = @a - @b;
END;
optional SQL check lines for testuser
USE testdb;
SELECT * FROM animals;
SELECT count(*) FROM animals;
SELECT count(*) FROM animals WHERE id!=1;
SELECT dbo.factorial(2);
SELECT dbo.factorial(3);
SELECT dbo.factorial(4);
DECLARE @a INT = 12;
DECLARE @b INT = 5;
DECLARE @x INT;
DECLARE @y INT;
PRINT 'a = ' + CONVERT(VARCHAR(6), @a);
PRINT 'b = ' + CONVERT(VARCHAR(6), @b);
EXECUTE dbo.add_and_subtract @a, @b, @x OUT, @y OUT;
PRINT 'x = ' + CONVERT(VARCHAR(6), @x);
PRINT 'y = ' + CONVERT(VARCHAR(6), @y);
Console applications for JSON communication with my public available mortgage calculation REST service. Complete example collection. Code for Java built by the Maven, for Java built by the Gradle, for C# built by the .NET Framework, for PHP and for Python.
Console applications for JSON communication with my public available bank account validator and converter REST service. Complete example collection. Code for Java built by the Maven, for Java built by the Gradle, for C# built by the .NET Framework, for PHP and for Python.
Console applications for JSON communication with my public available state, territory, continent and area code REST service. Complete example collection. Code for Java built by the Maven, for Java built by the Gradle, for C# built by the .NET Framework, for PHP and for Python.
Console applications for connection to the MySQL, how to update rows, how to read the table and how to call the stored function and the stored procedure. Complete example collection including Docker and SQL init. Code for Java built by the Maven, for Java built by the Gradle, for C# built by the .NET Framework and for PHP.