I am creating a SharePoint hosted App where I need some data from SQL table. As my major work is on SharePoint list only,hence I don't want to go for Provider hosted App. Could you please provide me with any code or way to connect to SQL and fetch data from remote SQL server. It would be very helpful.
You can't securely connect to a database from a SharePoint hosted app since it runs client side. You can write a web service and connect to your web service from within your app. But then you need to figure out how to secure your web service.