I am new to sql server .I have recently downloaded Sqlserver 2008 and connected from vb.net . I am trying to create dynamic tables
with two columns such as
name,amount by passing table
names from text box .
CREATE TABLE " & TblName & "( [Name] TEXT(10), [Amount] TEXT(6))]
table1
name | amount
a | 40
b | 60
table2
name | amount
a | 150
b | 50
I want to display output like this
table name| total
table1 | 100
table2 | 200
I can retrieve table names using the below query
SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
I have tried the query
it displays a empty column
"SELECT 'SELECT ISNULL(SUM('+COLUMN_NAME + '),0) AS a FROM ' + TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME = 'amount'"
I would like to know
Is it possible to write a query without specifying table name?
thanks