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)
 using nested string functions getting syntax error

Author  Topic 

MarkInKeizer
Starting Member

2 Posts

Posted - 2013-08-14 : 13:21:22
I'm a VB6/Access VBA developer and nesting together string functions to get a result is pretty standard stuff. I'm thinking it's not supported in SQL Server based on this. Is that true or do I have a bonehead error in here I'm simply not seeing? Thanks

SELECT FD.FieldID_FK
,F.TableName
,F.FieldName
,FD.FieldDescription
,SUBSTRING(FD.FieldDescription,charindex('CODE DESC',FD.FieldDescription),LEN(FD.FIELDDESCRIPTION) as fldGroupID
FROM [reference].[meta].[tblFIELDS_DESCRIPTION] FD, reference.meta.tblFIELDS F
WHERE fielddescription like '%CODE_DESC%' and
F.fieldid = FD.fieldid_fk

-----
Msg 156, Level 15, State 1, Line 5
Incorrect syntax near the keyword 'as'.

VERSION INFO BELOW
SQL Server version 2005 -- 9.00.3042.00 SP2 Standard Edition (we'll be on 2008R2 in about two weeks).
Microsoft SQL Server Management Studio 10.0.2531.0
Microsoft Analysis Services Client Tools 10.0.1600.22
Microsoft Data Access Components (MDAC) 3.85.1132
Microsoft MSXML 2.6 3.0 4.0 5.0 6.0
Microsoft Internet Explorer 8.0.6001.18702
Microsoft .NET Framework 2.0.50727.3615
Operating System 5.1.2600

Captain Kirk will be blasting Klingons before my employer retires WinXP Pro.
Mark

~Mark

MuMu88
Aged Yak Warrior

549 Posts

Posted - 2013-08-14 : 13:40:26

You are missing a parenthesis before 'as'
quote:
Originally posted by MarkInKeizer

I'm a VB6/Access VBA developer and nesting together string functions to get a result is pretty standard stuff. I'm thinking it's not supported in SQL Server based on this. Is that true or do I have a bonehead error in here I'm simply not seeing? Thanks

SELECT FD.FieldID_FK
,F.TableName
,F.FieldName
,FD.FieldDescription
,SUBSTRING(FD.FieldDescription,charindex('CODE DESC',FD.FieldDescription),LEN(FD.FIELDDESCRIPTION)) as fldGroupID
FROM [reference].[meta].[tblFIELDS_DESCRIPTION] FD, reference.meta.tblFIELDS F
WHERE fielddescription like '%CODE_DESC%' and
F.fieldid = FD.fieldid_fk

-----
Msg 156, Level 15, State 1, Line 5
Incorrect syntax near the keyword 'as'.

VERSION INFO BELOW
SQL Server version 2005 -- 9.00.3042.00 SP2 Standard Edition (we'll be on 2008R2 in about two weeks).
Microsoft SQL Server Management Studio 10.0.2531.0
Microsoft Analysis Services Client Tools 10.0.1600.22
Microsoft Data Access Components (MDAC) 3.85.1132
Microsoft MSXML 2.6 3.0 4.0 5.0 6.0
Microsoft Internet Explorer 8.0.6001.18702
Microsoft .NET Framework 2.0.50727.3615
Operating System 5.1.2600

Captain Kirk will be blasting Klingons before my employer retires WinXP Pro.
Mark

~Mark

Go to Top of Page

MarkInKeizer
Starting Member

2 Posts

Posted - 2013-08-14 : 14:24:55
That was it, thanks MuMu88



~Mark
Go to Top of Page
   

- Advertisement -