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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 substring function does not work in openrowset

Author  Topic 

ZenRoe
Starting Member

14 Posts

Posted - 2008-12-15 : 10:16:57
Good day all,
Using a substring in the condition clause of an openrowset query hits an error. Here's the query:
SELECT *
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=E:\CT\LoadStage\rawin.xls','SELECT [Address line 5] FROM [Sheet1$a1:z] where substring([Address line 5],1,2) = ''CH'' ')

Using the same substring in the select part works fine. Now is this a limit on the OPENROWSET end or am I the limit ?
Thanks for your help.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-15 : 10:32:30
i dont think it will be a problem. any ways try like this too

SELECT * 
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=E:\CT\LoadStage\rawin.xls','SELECT [Address line 5] FROM [Sheet1$a1:z] where [Address line 5] LIKE ''CH%'' ')
Go to Top of Page

ZenRoe
Starting Member

14 Posts

Posted - 2008-12-16 : 02:06:03
Ah, why did I not thought of that ? The like version works fine for me. Thanks !
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-16 : 02:08:18
welcome
Go to Top of Page
   

- Advertisement -