Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 18th, 2006, 01:05 PM
Authorized User
 
Join Date: Jan 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default strange problem in executing a query

hi all,
i am facing a strange problem. this is a set of sql statements i am trying to execute. fn_split is the function to split a delimited string. now this was working fine in one sql server, but when i tried running it on another server it says:--
      Server: Msg 446, Level 16, State 9, Line 4
      Cannot resolve collation conflict for like operation.

declare @list varchar(100)
select @list='somename'
select @list=(select parlst from rr_aw_det where aname=@aname)
select pcod
from rr_par_des,fn_split(@list,',')
where rr_par_des.pcod like value+'%'


i am unable to understand , the things which are working fine in one server are unable to run on another.
Any pointers to these will be of great help.


regards
rahul pokharna
__________________
regards
rahul pokharna
 
Old January 19th, 2006, 03:14 AM
Authorized User
 
Join Date: Jan 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Adding info about fn_split. this splits the delimeted string into rows. for ex

delcare s varchar(100)
set s='dfdf,dff,dd,'
select * from fn_split(s,',')
will give the result

idx value
0 dfdf
1 dff
2 dd


regards
rahul pokharna
 
Old January 20th, 2006, 02:23 PM
Authorized User
 
Join Date: Oct 2005
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Looks like you are using the LIKE operator in your fn_split function and it is using a different collation compared to the collation used in your table. Post your fn_split function to help us better understand the problem.

SQL Server Helper
http://www.sql-server-helper.com
 
Old January 21st, 2006, 11:42 PM
Friend of Wrox
 
Join Date: Dec 2005
Posts: 146
Thanks: 0
Thanked 1 Time in 1 Post
Default

See the response I gave to the same question in your other topic:
Moving the database to another Server

David Lundell
Principal Consultant and Trainer
www.mutuallybeneficial.com
 
Old February 10th, 2006, 10:50 AM
Authorized User
 
Join Date: Jan 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi David and sshelper i am giving the code for fn_split and the tables i created . please now let me know y the thing is not working as described above

Tables
rr_aw_det

CREATE TABLE [dbo].[rr_aw_det] (
    [aid] [varchar] (8000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
    [aname] [varchar] (8000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
    [maxno] [varchar] (8000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
    [parlst] [varchar] (8000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
    [status] [varchar] (8000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
)

rr_par_des

CREATE TABLE [dbo].[rr_par_des] (
    [pcod] [char] (5) COLLATE Latin1_General_CI_AS NOT NULL ,
    [pcat] [varchar] (50) COLLATE Latin1_General_CI_AS NOT NULL ,
    [pdes] [varchar] (100) COLLATE Latin1_General_CI_AS NOT NULL ,
    [Control_Type] [int] NULL ,
    [Property] [nvarchar] (1000) COLLATE Latin1_General_CI_AS NULL
)

and fn_split

CREATE FUNCTION fn_Split(@sText varchar(8000), @sDelim varchar(20) = ' ')
RETURNS @retArray TABLE (idx smallint Primary Key, value varchar(8000))
AS
BEGIN
DECLARE @idx smallint,
    @value varchar(8000) ,
    @bcontinue bit,
    @iStrike smallint,
    @iDelimlength tinyint

IF @sDelim = 'Space'
    BEGIN
    SET @sDelim = ' '
    END

SET @idx = 0
SET @sText = LTrim(RTrim(@sText))
SET @iDelimlength = DATALENGTH(@sDelim)
SET @bcontinue = 1

IF NOT ((@iDelimlength = 0) or (@sDelim = 'Empty'))
    BEGIN
    WHILE @bcontinue = 1
        BEGIN

--If you can find the delimiter in the text, retrieve the first element and
--insert it with its index into the return table.

        IF CHARINDEX(@sDelim, @sText)>0
            BEGIN
            SET @value = SUBSTRING(@sText,1, CHARINDEX(@sDelim,@sText)-1)
                BEGIN
                INSERT @retArray (idx, value)
                VALUES (@idx, @value)
                END

--Trim the element and its delimiter from the front of the string.
            --Increment the index and loop.
SET @iStrike = DATALENGTH(@value) + @iDelimlength
            SET @idx = @idx + 1
            SET @sText = LTrim(Right(@sText,DATALENGTH(@sText) - @iStrike))

            END
        ELSE
            BEGIN
--If you can’t find the delimiter in the text, @sText is the last value in
--@retArray.
 SET @value = @sText
                BEGIN
                INSERT @retArray (idx, value)
                VALUES (@idx, @value)
                END
            --Exit the WHILE loop.
SET @bcontinue = 0
            END
        END
    END
ELSE
    BEGIN
    WHILE @bcontinue=1
        BEGIN
        --If the delimiter is an empty string, check for remaining text
        --instead of a delimiter. Insert the first character into the
        --retArray table. Trim the character from the front of the string.
--Increment the index and loop.
        IF DATALENGTH(@sText)>1
            BEGIN
            SET @value = SUBSTRING(@sText,1,1)
                BEGIN
                INSERT @retArray (idx, value)
                VALUES (@idx, @value)
                END
            SET @idx = @idx+1
            SET @sText = SUBSTRING(@sText,2,DATALENGTH(@sText)-1)

            END
        ELSE
            BEGIN
            --One character remains.
            --Insert the character, and exit the WHILE loop.
            INSERT @retArray (idx, value)
            VALUES (@idx, @sText)
            SET @bcontinue = 0
            END
    END

END

RETURN
END



Please help me out of this...


regards
rahul pokharna





Similar Threads
Thread Thread Starter Forum Replies Last Post
strange IE problem sully7 BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 3 September 19th, 2008 08:44 AM
Executing an SQL query and using it's result Andrew.Berry ASP.NET 2.0 Professional 5 April 14th, 2008 08:25 AM
Strange problem... F3553 C++ Programming 1 October 25th, 2007 03:56 PM
Executing a query from SQL server to Oracle DB SoCalProgAna SQL Server 2000 7 March 24th, 2006 08:15 AM
Strange join query nikosdra SQL Language 1 August 10th, 2003 06:10 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.