Categories
SQL

Stored Procedures

Creating CREATE PROCEDURE sp_GetRecord @pro_num varchar(10) AS SELECT * FROM DATA_DETAILS WHERE pro_number = @pro_num Executing EXECUTE sp_GetRecord ‘16571565’

Categories
SQL

Insert data from one table to another table

INSERT INTO “table1” (“column1”, “column2”, …) SELECT “column3”, “column4”, … FROM “table2” INSERT INTO Store_Information (store_name, Sales, Date) SELECT store_name, Sales, Date FROM Sales_Information WHERE Year(Date) = 1998

Categories
SQL

SQL Select leftmost or rightmost characters from rows of data

SELECT left(item_num, 4) FROM flowers; If item_num = 754861 then the output will be: 7548 SELECT right(item_num, 4) FROM flowers; If item_num = 754861 then the output will be: 4861

Categories
SQL

Uniqueidentifier (T-SQL)

UniqueIdentifier is a 16-byte GUID. The uniqueidentifier type is limited to 36 characters, the characters that exceed that length are truncated A column or local variable of uniqueidentifier data type can be initialized to a value in the following ways: By using the NEWID function. By converting from a string constant in the form xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, […]