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)
 Square brackets

Author  Topic 

trouble2
Constraint Violating Yak Guru

267 Posts

Posted - 2008-08-01 : 08:43:20
Hi, on my testserver I am using:

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[FoodService_Product_SearchProducten2]
@Trefwoord varchar(255),
@Soorten varchar(255),
@Ranges varchar(255)
AS
SELECT DISTINCt
t1.[ProductID]
,t1.[Artikelcode]
,t1.[Productnaam]
,t1.[Gewicht]
,t1.[StuksInDoos]
,t1.[DozenPerPallet]
,t1.[Bereiding]
,t1.[KleineFoto]
,t1.[GroteFoto]
,t1.[KorteOmschrijving]
,t1.[LangeOmschrijving]
,t1.[Trefwoorden]
,t1.[GerelateerdeProducten]
,t1.[ExtraInformatie]
,t1.[Aanduiding]
,t1.[PDF]
,t1.[ProductType]
,t1.[ProductSoort]
,t1.[ProductCategorie]
,t1.[ProductRange]
,t1.[InvoerDatum]
,t1.[LaatstGewijzigd]
FROM
[dbo].[Foodservice_Producten_Product] t1
CROSS APPLY dbo.ParseValues(t1.ProductSoort) b
CROSS APPLY dbo.ParseValues(t1.productRange) c
Where
(
@Soorten = ''
OR
',' + @soorten + ',' like '%,' + cast(b.val as varchar(10)) + ',%'
)
AND
(
@Ranges = ''
OR
',' + @Ranges + ',' like '%,' + cast(c.val as varchar(10)) + ',%'
)
AND
(
@Trefwoord = ''
OR
(
([Productnaam] like '%' + @Trefwoord + '%')
OR
([Artikelcode] like '%' + @Trefwoord + '%')
OR
([KorteOmschrijving] like '%' + @Trefwoord + '%')
OR
([LangeOmschrijving] like '%' + @Trefwoord + '%')
OR
([Trefwoorden] like '%' + @Trefwoord + '%')
OR
([ExtraInformatie] like '%' + @Trefwoord + '%')
)
)

without any problems.

Now when I try to add the SP on the production server I get:

Msg 102, Level 15, State 1, Procedure FoodService_Product_SearchProducten2, Line 32
Incorrect syntax near '.'.

So this is here:

CROSS APPLY dbo.ParseValues(t1.ProductSoort) b

It looks like I need to add []'s somewhere, but whatever I try, I can't get it to work.
Anyone has an idea?

RyanRandall
Master Smack Fu Yak Hacker

1074 Posts

Posted - 2008-08-01 : 08:57:16
Why do you think it's a square bracket problem?

What version is your production server?

Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
Go to Top of Page

trouble2
Constraint Violating Yak Guru

267 Posts

Posted - 2008-08-01 : 09:01:25
Test is 9.0.3068, production is 9.0.3042
Go to Top of Page

trouble2
Constraint Violating Yak Guru

267 Posts

Posted - 2008-08-01 : 09:12:09
Can someone help me out, I think there must be an easy solution.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-08-04 : 06:36:47
what is your database compatibility level ? set it to 90


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

trouble2
Constraint Violating Yak Guru

267 Posts

Posted - 2008-08-04 : 06:59:30
Hey khtan, thanks!!!

They had it set on 80, losers....


The secret to creativity is knowing how to hide your sources. (Einstein)
Go to Top of Page
   

- Advertisement -