Friday, October 4, 2013

SQL - Declare a Table Variable

DECLARE @table_membership TABLE(   seq_id int identity(1,1),
                                            name varchar(1000) NOT NULL,
                                            contact varchar(1000) NOT NULL,
                                            type_sort int NOT NULL,

                                   )

SQL - Update Table From Itself


UPDATE a
SET a.Price=(SELECT MAX(b.PRICE) FROM ITEM AS b WHERE b.Item=a.Item and b.Price is not null )
FROM  Item AS a 


*credit goes to this post: http://stackoverflow.com/questions/12151107/tsql-update-table-from-itself