Click here to Skip to main content
15,914,225 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Friends,
I am unable in getting table name with defined cell of defined column is blank in sql.
Can anyone help me.
Thanks,
Akkywadhwa
Posted
Comments
Akkywadhwa 14-May-12 12:08pm    
Consider 2 tables named name1 and name2 in database xyz.These tables contain time-table schedule of a teacher tells him/her that in which class he/she has to go in the specified 8 period in 6 days.And some of them are free too.Cells are denoting free periods by null values.So, I need to retrieve the tables names that is name1 and name2 by applying query that:

Give me those table names which contain null values in period 3 on day 4.
Please help me out as soon as it could be possible.
Regards,
Akkywadhwa

Do you mean that when you query data from a table you don't get results if the value in the column is empty? If that's the case then you must use IS NULL condition in your query. For example
SQL
SELECT * FROM TableName WHERE ColumName IS NULL;
 
Share this answer
 
Comments
Akkywadhwa 12-May-12 14:25pm    
I can't specify table name in my query as i have to retrieve it.
Example:
There is a table named akky which has 2nd colums 3rd cell empty then it must return me akky.
Note: Value of column and row is specified by me.
Thanks,
Akkywadhwa
Wendelius 12-May-12 14:59pm    
Now I don't quite understand. When you select from a table, you need to know the table name. For example:

SELECT * FROM Akky

Also you have two columns in your table, but what is third cell? Do you mean third row? If that's the case, then you should define the order based on something. Basically the rows in the table are in no specific order.

Could you clarify this with an example and post the query you have so far.
Akkywadhwa 14-May-12 12:06pm    
Consider 2 tables named name1 and name2 in database xyz.These tables contain time-table schedule of a teacher tells him/her that in which class he/she has to go in the specified 8 period in 6 days.And some of them are free too.Cells are denoting free periods by null values.So, I need to retrieve the tables names that is name1 and name2 by applying query that
Give me those table names which contain null values in period 3 on day 4.
Please help me out as soon as it could be possible.
Regards,
Akkywadhwa
Wendelius 14-May-12 14:24pm    
This doesn't quite make sense. Most likely this is a terminology problem, but table cannot be null (unless it's a table variable). Table is the persistent entity in database containing the rows (zero or more). Table is created using a CREATE TABLE statement. Table has at least 1 but possibly more columns. The values in columns can be null (empty).

So are you trying to find the rows containing a null value in a specific column? Please list the table structure. It would help a lot solving this issue.
To get table name by column name, use this:
SQL
SELECT t.name As TableName, c.Column_Name
FROM sys.tables t INNER JOIN information_schema.columns c ON c.Table_Name = t.Name
WHERE [Column_Name] = @ColName
 
Share this answer
 
v2

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