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
 Development Tools
 ASP.NET
 Why am I getting Invalid column name ?

Author  Topic 

fonzie
Starting Member

31 Posts

Posted - 2005-11-23 : 10:09:07
I am getting Invalid column name 'substr(NOUN,1,17)'
in my select statement? Am I not allowed to select a partial string?

SelectCommand="SELECT [OFFICE], [substr(NOUN,1,17)] from ......"

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2005-11-23 : 10:13:08
the sub string function is substring

-----------------
[KH]
Go to Top of Page

fonzie
Starting Member

31 Posts

Posted - 2005-11-23 : 12:35:56
I tried that too: Invalid column name 'substring(NOUN,1,17)'.
server is SQLserver
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2005-11-23 : 13:51:41
SelectCommand="SELECT [OFFICE], [substr(NOUN,1,17)] from ......"

Should be

SelectCommand="SELECT [OFFICE], SUBSTRING([NOUN],1,17) FROM ......"

And you also should be using stored procedures instead of dynamic sql

Have a DB2 Background?

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-11-24 : 00:29:59
>>[substr(NOUN,1,17)]

As you used squre braces, it is treated as a column so as the error

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -