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.
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 @sqlSet @sql = substring(@sql,1 , len(@sql) - 1) Print @sqlServer 1 resultsSelect * from Fiat_Inbound , Select * from Fiat_Inbound Note the trailing comma has been deletedServer 2 resultsSelect * from Fiat_Inbound , Select * from Fiat_Inbound ,Note comma still present.Declare @sql nvarchar(max)set @sql = 'Select * from Fiat_Inbound , 'Print @sqlset @sql = ltrim(rtrim(@sql))Set @sql = substring(@sql,1 , len(@sql) - 1) Print @sqlThis now works, however I really need to get my two database working the same way rather than patching the problem.Anybody got any ideas?regardsTom |
|
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? |
 |
|
|
|
|
|
|