Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Sample of Update~Delete with OUTPUT clause (2016 >)
/* Microsoft TSQL Crash Course http://www.forta.com/books/0672337924/ Setup: */ CREATE TABLE customers ( cust_id INT NOT NULL IDENTITY(1,1) , cust_name NCHAR(50) NOT NULL , cust_address NCHAR(50) NULL , cust_city NCHAR(50) NULL , cust_state NCHAR(5) NULL , cust_zip NCHAR(10) NULL , cust_country NCHAR(50) NULL , cust_contact NCHAR(50) NULL , cust_email NCHAR(255) NULL ); SET IDENTITY_INSERT customers ON; INSERT INTO customers (cust_id , cust_name , cust_address , cust_city , cust_state, cust_zip , cust_country , cust_contact , cust_email) VALUES (10001 , 'Coyote Inc.' , '200 Maple Lane' , 'Detroit' , 'MI' , '44444' , 'USA' , 'Y Lee' , 'ylee@coyote.com' ) ,(10002 , 'Mouse House' , '333 Fromage Lane' , 'Columbus', 'OH' , '43333' , 'USA' , 'Jerry Mouse' , null ) ,(10003 , 'Wascals' , '1 Sunny Place' , 'Muncie' , 'IN' , '42222' , 'USA' , 'Jim Jones' , 'rabbit@wascally.com' ) ,(10004 , 'Yosemite Place' , '829 Riverside Drive' , 'Phoenix' , 'AZ' , '88888' , 'USA' , 'Y Sam' , 'sam@yosemite.com' ) ,(10005 , 'E Fudd' , '4545 53rd Street' , 'Chicago' , 'IL' , '54545' , 'USA' , 'E Fudd' , null ) ; SET IDENTITY_INSERT customers OFF; SELECT '-- CUSTOMERS table loaded...' as "-- comment1"; SELECT '-- Sample UPDATE with OUTPUT...' as "-- comment2"; UPDATE customers SET cust_state = Upper(cust_state) OUTPUT DELETED.* ;
run
|
edit
|
history
|
help
0
sqlserver
Train Reservation
Test row_number() ordering when CTE referenced multiple times
Mywall
db6
search all tables for string
heyy
check constraint
STDEV vs STDEVP
variables and table variables inside a cursor loop