Click here to Skip to main content
15,440,308 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
hi,

can i create sql query in query builder by selecting sql views instead of selecting sql tables??
please someone help me...!
Posted
Updated 28-Oct-15 4:19am
v2

1 solution

Yes. It is common practice.

When adding tables, the second tab should be "Views"
 
Share this answer
 
Comments
Member 12094561 29-Oct-15 1:44am     CRLF
hi, sorry i guess,my question was not clear to u,.. my question was..in query builder we select some tables from database and we generate the query right... In the same manner i want to generate a query by selecting sql views instead of selecting tables.... Regards Pavan
Andy Lanng 29-Oct-15 4:59am     CRLF
Query builder in SQL Management Studio? There is a table next to tables when selecting tables for views. Or are you using a different 'Query Builder'? There are many :S
Member 12094561 29-Oct-15 8:39am    
i want to share an screenshot,is there any way here to share??so that ul get an clear idea of my req.
Member 12094561 29-Oct-15 8:42am     CRLF
http://www.sourcecodester.com/tutorials/visual-basic-net/5889/simple-query-builder-using-visual-basicnet.html once go though this link...u will understand,what i want...in that link he is selecting tables to generate query,..bt i want to select views instead of tables..please go through that link
Andy Lanng 29-Oct-15 9:11am     CRLF
Ah - I see. That's dead simple. You have a query that shows tables: "SHOW TABLES FROM [db]" This will return all tables and views by default. You can check the type by using the query: "SHOW FULL TABLES FROM [db]" That will return two columns. The table and the table type ("BASE TABLE"|"VIEW") but in order to use them, you have to perform a "SELECT" instead of a "SHOW". That's a little different: "SELECT CONCAT(Table_name," (", Table_Type, ")") AS 'tables_in_[db]' FROM information_schema.Tables WHERE Table_schema = '[db]'" You can use that query in place of "SHOW TABLES FROM " & cbdb.Text and it will show the values as: "tablename (BASE TABLE)" and "viewname (VIEW)". To be clear: Replace the line: Dim sql As String = "SHOW TABLES FROM " & cbdb.Text with Dim sql As String = String.Format("SELECT CONCAT(Table_name," (", Table_Type, ")") AS 'tables_in_{0}' FROM information_schema.Tables WHERE Table_schema = '{0}' ", cbdb.Text)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900