The Evil That is "Select *"
I'm using this way. SELECT * FROM VIEW. Consider the below Table has following fields(Including Non-display columns).Table...
I'm using this way.
SELECT * FROM VIEW
. Consider the below Table has following fields(Including Non-display columns).
Table Structure
----------------------------------------------------------------------- tbl_Person ----------------------------------------------------------------------- ID PersonCode PersonName DateOfBirth Gender Address1 Address2 Address3 Zipcode Phone Fax Mobile Email Website CreatedOn CreatedBy ModifiedOn ModifiedBy Status -----------------------------------------------------------------------Now I'm creating View & Stored procedure with only columns which to be displayed(except Audit columns & some other) in UI. View & Stored Procedure
CREATE VIEW vwPersonDetails AS SELECT PersonCode, PersonName, DateOfBirth, Gender, Address1, Address2, Address3, Zipcode, Phone, Fax, Mobile, Email, Website FROM tbl_Person
CREATE PROCEDURE Usp_PersonDetails AS SELECT PersonCode, PersonName, DateOfBirth, Gender, Address1, Address2, Address3, Zipcode, Phone, Fax, Mobile, Email, Website FROM tbl_PersonFinally I'm using the below one for execution. If you add new columns in table it won't make any changes in View or stored procedure until the modification. So when ever need to display new columns, I'll change the View or stored procedure.
SELECT * FROM vwPersonDetails EXEC Usp_PersonDetails