Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Check null

Author  Topic 

mihir.mone
Starting Member

17 Posts

Posted - 2009-07-01 : 00:21:56
Hello,
I am working on import feature(.xls).
A valid .xls file contains first column to be Sr.No. which should not be null.

I want to write a query to load resultant data in dataset.
Query should pick only those records which has non null value in the first column.

e.g.
sr.no Firstname qualification
1 Mihir MCA
2 Rob Doc

One more thing, first column name can be anything.
Can we use column index instead of column name in a query?

rajdaksha
Aged Yak Warrior

595 Posts

Posted - 2009-07-01 : 05:54:02
Am not sure. you asking query or else....
SELECT * FROM TABLE_NAME WHERE First_NAME IS NOT NULL
Go to Top of Page

mihir.mone
Starting Member

17 Posts

Posted - 2009-07-01 : 06:23:26
I wanted to know if we can use Column index/number instead of column name in a Select query
Go to Top of Page

malaytech2008
Yak Posting Veteran

95 Posts

Posted - 2009-07-01 : 06:52:31
you can set in where clause.

Malay
Go to Top of Page

mihir.mone
Starting Member

17 Posts

Posted - 2009-07-01 : 06:57:18
Thanks,

but can you please write it?
Go to Top of Page

rajdaksha
Aged Yak Warrior

595 Posts

Posted - 2009-07-01 : 06:58:00
SELECT A.[Index], A.Name
...
UNION

SELECT A.[Index], A.Name
... ORDER BY A.[Index]

Go to Top of Page

mihir.mone
Starting Member

17 Posts

Posted - 2009-07-01 : 07:21:11
Sorry I doesnt work.

I tried -
SELECT * FROM tbl_Employees Emp WHERE Emp.[1] IS NOT NULL
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-07-01 : 07:30:03
No, you can use a relative position as column reference in a SELECT clause.



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

mihir.mone
Starting Member

17 Posts

Posted - 2009-07-01 : 07:39:46
Sorry,
I did not understand.
I am not good enough in SQL.
Just wanted to optimize my code through this.

Can you please write it in same query, which I used?
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-07-01 : 08:09:04
quote:
SELECT * FROM TABLE_NAME WHERE First_NAME IS NOT NULL

Or SELECT * FROM TABLE_NAME WHERE First_NAME > ''


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -