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
 Database Design and Application Architecture
 i want write select without field name

Author  Topic 

mohinsoft
Starting Member

7 Posts

Posted - 2008-03-22 : 14:54:30
hello
my friends
i want write Select without write filed name
example
mytable(id,name1,family)
orginal selected is
select id,name1 from mytable
but i want write:
select field[0],field[1] from my table
that field[0] point to id and field[1] point to name1
thanx

M.O.H.I.N

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-03-22 : 15:13:35
you mean select * from ... ?
but why would you want to do that??

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com
Go to Top of Page

mohinsoft
Starting Member

7 Posts

Posted - 2008-03-22 : 15:30:38
my friend i want import special fileds data from excel to my table in sql
and i dont know field name in excel therefore i want access to fields in excel without name or access via number of field and dont use from *
my code is:
insert into mytable(id1,name1,family) ---> {this is in sql}
' select * from OPENROWSET('
'Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=c:\test1.xls;',
'SELECT *{problem is here} FROM [testsheet$]'
{problem is here}--->i dont use * and i dont know field name i want use
select field[0],field[1],field[2] from [testsheet$]


M.O.H.I.N
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-03-22 : 15:44:14
nope.. you can't do what you want in this way
import your excel into a temporary table and then insert from this temp table to your main table

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com
Go to Top of Page
   

- Advertisement -