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
 Other SQL Server Topics (2005)
 Difference between two instances of SQL 2005

Author  Topic 

tom.williams
Starting Member

1 Post

Posted - 2008-12-09 : 08:30:40
Hi all,

I am trying to migrate some code from one database to a new database to release resource on the first DB.

I have a stored procedure which loops through creating generic SQL, this has been working for months on the original server.

The problem I have is that a substring command is not returning the same results on the new server?

Declare @sql nvarchar(max)
set @sql = 'Select * from Fiat_Inbound , '
Print @sql
Set @sql = substring(@sql,1 , len(@sql) - 1)
Print @sql

Server 1 results

Select * from Fiat_Inbound ,
Select * from Fiat_Inbound

Note the trailing comma has been deleted

Server 2 results
Select * from Fiat_Inbound ,
Select * from Fiat_Inbound ,

Note comma still present.

Declare @sql nvarchar(max)

set @sql = 'Select * from Fiat_Inbound , '
Print @sql
set @sql = ltrim(rtrim(@sql))
Set @sql = substring(@sql,1 , len(@sql) - 1)
Print @sql

This now works, however I really need to get my two database working the same way rather than patching the problem.

Anybody got any ideas?

regards

Tom

brianjensen
Starting Member

22 Posts

Posted - 2008-12-09 : 09:01:28
I have run both queries on a couple of different SQL instances (express 2, enterprise 2005 sp 2, 2008 enterprise) and they both produce the same result which makes sense since the you are using a varchar which "auto" rtrims.

Are both your servers installed with the same settings and are they both patched to the same SP level?
Go to Top of Page
   

- Advertisement -