Replace Function Not Working

Oct 19, 2005

Hi,
I posted a request here and am still working on it when I landed on this bug.


select top 10 replace(comma_separated_string,',','giveaverylongp assagehere') from table



The function works fine if the comma separated string is small or if the passage is small. It fails for long passages..

Is this a mssql bug?

View 1 Replies


ADVERTISEMENT

Replace NOT Working!!!

Jun 24, 2008

hi, I'm trying to get rid of the intermediate double space from the following string:

DOC-#911585 P.O.-Box-41

so I do:

select replace('DOC-#911585 P.O.-Box-41',' ','-')
and it yields:

DOC-#911585--P.O.-Box-41

BUT

if I do:
select replace(fieldFrommyTable,' ','-') from myTable
where myaddressVal='DOC-#911585 P.O.-Box-41'

SQL Server does nothing with the double white space...
the double space remains, what am I missing?

HELP!

thank you

View 8 Replies View Related

Why Is Not Working Select REPLACE(strata, '_*','**') As Abc From Abc??

May 5, 2008

why is not working

select REPLACE(strata, '_*','**') as abc from abc
??

I want to replace sign "*" and preceding

sign with "**" signs.

thank you

View 17 Replies View Related

Replace Zeros And Nulls With 1 In Table -- Using Case, But Not Working

Jul 20, 2005

Hi folks,I'm doing calculations based on data in a table, but the data has somezeros in the field I'm dividing by. I'm trying to write a script toreplace any field with 0 or null with 1, but it's not working. HEre'swhat I've got:Update A Set A.deptcode = A.deptcode,A.type = A.Type,A.Volume = (case A.VolumeWhen Null Then 1When 0 then 1Else A.VolumeEnd)From Data_Unsorted A Join Data_Unsorted B OnA.deptcode = B.deptcode and A.type = B.TypeMy table is data_unsorted and deptcode and type are my primary keysVolume is the item I want to put 1 if null or zero, and I'd thing theabove statement would work, but it doesn't. This table has 383 rows,and it says it updates 383 rows, but when I run the following query totest:select a.deptcode, a.type, a.volumefrom data_unsorted awhere a.AveMonthVolume = 0 or a.AveMonthVOlume is nullIt didn't work... still TONS of nulls and zero's. Is there a trick tothis???Thanks,Alex.

View 2 Replies View Related

Replace Function In SQL?

Oct 30, 2003

Hi,

I have a table with a field called productname, and it has about 5000 rows, and within that about 1000 have a productname that has 'NIB' in the name, ie "My Product NIB DVD" and I have been asked to replace 'NIB' with 'New' ie "My Product New DVD" Can I do this in SQL using an Update statement? Or do I have build something in maybe asp.net to use a replace function to change the name.

Thanks

View 9 Replies View Related

Using Replace Function

Aug 10, 2004

I am using MSDE. In this I have a field that contains a desciption. Prior to saving to the db, I replace all vbcrlf's to <br />'s. That works fine when displaying in HTML, but when I display it in a datagrid, I want to replace the <br />'s with vbcrlf's.

I thought I might be able to do it with a replace function in my SQL query, something like "Select ID, replace(Description, '<br />', vbcrlf) as Description". This produces an error that vbcrlf is not a fieldname. So I tried "select replace(Description, '<br />', 'xxx') as Description", and while this did not create an error, neither was the text replaced.

Am I not using the replace function correctly? Is there another way in which I might accomplish the task?


Dim ConnectionString As String = "server='(local)'; trusted_connection=true; database=dbname"
Dim CommandText As String

'Command text is greatly abreviated for this discussion.
CommandText = "Select ID, replace(Description, '<br />', vbcrlf) as Description"

Dim myConnection As New SqlConnection(ConnectionString)
Dim myCommand As New SqlDataAdapter(CommandText, myConnection)

Dim ds As New DataSet()
Dim dv as new dataview()
myCommand.Fill(ds)

DataGrid1.DataSource = ds
DataGrid1.DataBind()
...
...
...

View 3 Replies View Related

Using Like Function With Replace

Mar 28, 2006

I have a need to evaluate a parameter to use like keywords. (Not my server, so indexing is not available.) I can get the first scenario to work, but wanted to see about getting the syntax so I wouldn't have to exec the statement. If I run the first execute statement, I get three rows (accurate). If I run the second statement, I get no rows. Anybody help me out with the syntax? I've tried so many variations, I'm lost. Many thanks.

declare @key as varChar(50), @sql as varchar(1000)
set @key='flow afow'

set @sql='select myID from myTable where [title] like ''%' + replace(rtrim(ltrim(@key)),' ','%'' or [title] like ''%') + '%'''
exec(@sql)

select myID from myTable where [title] like '%' + replace(@key,' ', '%''' or [title] like '''%') + '%'

View 2 Replies View Related

REPLACE Function

May 17, 2002

I'm trying to replace some text in a field. It looks something like this:

63.73 Avail %= 36.27 Used space MB = 2609.34375 Free space MB = 1485.34765625

I only want the 63.73 number at the beginning. How do I put a wildcard to replace everything after it, starting with 'Avail...'?

View 4 Replies View Related

Does T-sql Has Replace(in Vb) Function?

May 12, 2004

I want to perform Replace(searchstring, oldstring, newstring) like function in T-sql as same as in VB..

is there existing one or any other user-defined function?

thanks...

View 2 Replies View Related

Using The REPLACE Function

Apr 16, 2007

Is it possible to replace 4 different values into one alias column?



ie REPLACE(EligStatus, '0', 'Verified') AS VRFD



..now I need to replace 3 other values with words but i want to keep them in the same VRFD column so I can add it to the report layout.



or is there a better way to do it?



I can't set up a linking table because nowhere in the DB are the values linked to the actual status.



Thanks in advance,



Mark.





View 4 Replies View Related

I Have A Problem With The Replace Function.

Aug 12, 2004

Let's try this again.
When I try to use the replace function in my query it ignores the "<" and ">" characters, so that this query:select Description, replace(Description, '<', '* * *') as [Description 1] , replace(Description, 'br /', '? ? ?') as [Description 2] from TT_Projects
produces these results:
Description | Description 1 | Description 2
testsfv <br /> | testsfv <br /> | testsfv <? ? ?> I also tried to replace char(60) with no success.

Any ideas why this is happening?

View 1 Replies View Related

Replace Function In Sql Statement

Oct 15, 2007

how should i use replace function in sql statement??

in my scenario, user enters the meeting ID and i want that if user enters the meeting ID which includes apostrophe('), the stored procedure should remove the apostrophe before inserting it into database table.

my stored procedure accepts two parameters.
Is there any way to solve my problem??


Jaimin

View 4 Replies View Related

Problem With Replace Function

Apr 9, 2007

Hi,Please find the below scenarioOriginal Tablecourse branch_existBY0UI1PO1LI0MK1select REPLACE(branch_exist,1,'yes') as branch from university;displayscourse branch_existBY0UIYesPOYesLI0MKYesWhat i need iscourse branch_existBYNoUIYesPOYesLINoMKYesSql-Server replace function only accepts three arguments, anysuggestions will be greatly welcomed!

View 3 Replies View Related

Using Replace Function With 2 Keywords To Look For

Oct 16, 2007



Hi,
We have this syntax from Microsoft for Replace function:

REPLACE ( string_expression1 , string_expression2 , string_expression3 )

I want to search for two keywords and not only one:
images and images/ (second one is with back slash.

Is it possible to include something like:

images/ OR images in expression2 like

REPLACE ( string_expression1 ,'images/ OR images', string_expression3 )

I want something like that, how do I get that please?

Thank you.

View 4 Replies View Related

Replace A Function By Pure T-SQL

May 20, 2008


I have 2 tables
1) One With ExchangeRates
a. CurrencyCode ValidFromPeriod Rate
b. EX1 200801 1
c. EX1 200803 2
d. EX1 200805 3
2) One with just OrderHeaders
a. ID CurrencyCode Period
b. 1 EX1 200801
c. 2 EX1 200802
d. 3 EX1 200803
e. 4 EX1 200804
f. 5 EX1 200805

The Idea is to link these orderheaders with their correct ExchangeRate. Which I only managed to do by using a function. Is there a beter (faster) way to do it?




Code Snippet
SELECT OrderHeaders.ID, OrderHeaders.CurrencyCode, OrderHeaders.Period, dbo.GetExchangeRate(OrderHeaders.CurrencyCode, OrderHeaders.Period) AS ExchangeRate FROM OrderHeaders

FUNCTION GetExchangeRate
@CurrencyCode VarChar(3),
@Period int
BEGIN
DECLARE @VarResult Float
SET @VarResult =0
SELECT TOP 1 @VarResult=Rate FROM ExchangeRates WHERE CurrencyCode=@CurrencyCode AND ValidFromPeriod<=@Period ORDER BY ValidFromPeriod DESC
Return @VarResult
END

View 8 Replies View Related

Replace Function: Replacing An Apostrophe With Whatever

Aug 7, 2007

heyi'm having a problem with a stored procedure, to cut a long story short i need to replace apostrophe's in my text, like soSET @prOtherValue = REPLACE(@prOtherValue,''', '''')this doesn't work thowhats the work aroundcheers!!!! 

View 6 Replies View Related

Remove And Replace Accents Function

Nov 2, 2005

does anyone know where i can find a user defined function that replaces accented characters with their normal ones

i want to replace all accented characters since for some reason sql server does not store the characters properly, or when they exported to excel for html they are displayed incorrectly

thanks

View 5 Replies View Related

Way To Improve Performance Without Using Replace Function

Feb 13, 2014

i have column in table which contains tabs and " i want replace with space...i am using repalce function is thier other way to improve performance with out using replace function.

View 9 Replies View Related

Replace Function And Regular Expressions

Jul 20, 2005

Is it possible to use the REPLACE function in SQL Server 2000 so thatit returns a string containing only alpha-numeric characters (muchlike using regular expressions)?Thank you in advance for any suggestion.Darren.

View 1 Replies View Related

Transact SQL :: Modify URL With Replace Function

Jul 1, 2015

Update query to modify a Url in the text column with another url

Ex:

Col1 Col2
1 An unexpected event occurred
https://abc.def.com/default/_workitem/10325
3  This alert occurs when service jobs run on
https://abc.def.com/default/_workitem/10118
10  This alert fired to indicated that error with
https://abc.def.com/default/_workitem/10150
to
Col1 Col2
1 An unexpected event occurred
https://abc.def.com/default/_workitem/11111
3 This alert occurs when service jobs run on
https://abc.def.com/default/_workitem/11111
10 This alert fired to indicated that error with
https://abc.def.com/default/_workitem/11111

View 3 Replies View Related

T-SQL (SS2K8) :: Enhanced Find And Replace Function

Apr 17, 2014

I'm looking for a way to pull off a complex find+replace within some code, as follows:

@step_name = N'SAME - OCF Collins (Tabard)', @command = N'DTSRun /~Z0x5F4F7B0688825E7544AC46CFD664F98AC ', @database_name = N'

We have over 200 variants of the above, but following the same syntax (@step_name, Dbname, @Command etc...

Rules:

1) Note the unique identifier "~Z0x5F4F7B0688825E7544AC46CFD664F98AC". I would like it replaced for whatever is between "@step_name = N'" , and @command = N'DTSRun ; (this will form a filename).

2) Note the 'DTSRun /' string. I'd like that replaced with Dtexec /F "D:MyFileLocationFolderHere" (this folder remains constant).

View 2 Replies View Related

Replace-type Function For Text Datatype

Jul 20, 2005

I have a table that has a Text datatype column that has gotten somegarbagecharacters in it somehow, probably from key entry. I need to removethe garbage, multiple occurances of char(15). The replace functiondoes not work on Text datatype. Any suggestions?

View 3 Replies View Related

Replacing Multiple Strings Using The REPLACE Function

Jul 9, 2007

I'm would like to replace all occurrences of "99999" and "-99999" with "" in a column using SSIS. I can use the REPLACE function in a Derived Column to replace one of those strings, for example: REPLACE(mycolumn,"99999",""). Or to replace both I could use REPLACE(REPLACE(mycolumn,"-99999",""),"99999",""). This seems kind of cumbersome and would get very complicated if I were replacing more strings with "". I'm guessing there is a better way. Can anyone help me out?

Thanks,
Ridium

View 12 Replies View Related

SQL Server 2012 :: Select Query With REPLACE Function?

May 22, 2015

using below code to replace the city names, how to avoid hard coding of city names in below query and get from a table.

select id, city,
LTRIM(RTRIM(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(city,
'JRK_Ikosium', 'Icosium'), 'JRK_Géryville', 'El_Bayadh'),'JRK_Cirta', 'Constantine'),'JRK_Rusicade', 'Philippeville'),
'JRK_Saldae', 'Bougie')))
New_city_name
from towns

View 3 Replies View Related

REPLACE Function Doesn't Work With Null-bytes

Feb 7, 2006

Dear Community,We have a problem with null-Bytes in varchar-Columns, which are nothandled correctly in our application. Therefor we try to filter themout using the Transact-SQL REPLACE function.The Problem was, that the REPLACE-function didn't behave the way weexpected.Following Example demonstrates the behavior:declare @txt varchar(512)declare @i intset @txt = 'hello ' + char(0) + 'world'print @txtset @i = 1while @i <= len(@txt)beginprint str(@i) + substring(@txt, @i, 1)set @i = @i + 1endprint 'Length: ' + str(len(@txt))print 'trying to replace null-byte:'print replace(@txt, char(0), '*')print 'replace Letter h'print replace(@txt, 'h', char(39))-- end exampleOutput:hello1h2e3l4l5o678w9o10r11l12dLength: 12trying to replace null-byte:*replace Letter h'elloThe Null-Byte replace destroys the whole string. This behavior occursonly on some of ourdatabases. The others work correctly.Is it possible that it depends on some server setting?ThanksEnno

View 5 Replies View Related

Sample Problem : Function Replace() In Derived Column

Mar 22, 2007

Hello All.

Hopefully someone out there will have an idea as this isdriving me nuts.
Ihave some sample problem. I want to use function replace() on Derived Column.
For example.
when strDate = 2007/03/22

I used ==> replace(strDate, "/", "") ==> 20060322

But If strTest = "123.10" ====>> 123.10

How can i do to replace ( " )double qoute ?
by function replace()

what is a statement for replace (") in Derived Column ?

please tell me for this event.

any suggesstion appreciated
Thank you very much.

Chonnathan

View 11 Replies View Related

How Can I Get This Function Be Working?

Jun 2, 2006

How can I get this function be working?
 
CREATE FUNCTION MyFunc
(
   @MyDate as datetime,
   @MyTableName varchar(50),
)
RETURNS TABLE
AS
RETURN 
  SELECT * FROM @MyTableName Where myDate=@MyDate
 

View 2 Replies View Related

How Can I Get This Function Be Working?

Jun 2, 2006

How can I get this function be working?

CREATE FUNCTION MyFunc
(
@MyDate as datetime,
@MyTableName varchar(50),
)
RETURNS TABLE
AS
RETURN
SELECT * FROM @MyTableName Where myDate=@MyDate

View 4 Replies View Related

C# Update Function. Where AND Where Not Working.

Jan 29, 2008

Can someone please tell me why in the bloody hell this isnt working? It ignores the WHERE VENDORID match portion and marks all instances of USERID match to TRUE. I've been banging my head for an hour... have I really forgotten basic sql???!!!!public static void UpdateVendor(VendorEvaluationEntity VEE)
{int vendorid = Convert.ToInt32(VEE.VendorevalVendor);
int userid = Convert.ToInt32(VEE.VendorevalUser);SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["VendorEvaluationConnectionString"].ConnectionString);
SqlCommand cmd = new SqlCommand("Update tblVendorUser set vendoruser_vendor_evaluated = 'true' where (vendoruser_vendor_id = @vendorid) and (vendoruser_user_id=@userid)", conn);SqlParameter pmvendorid = new SqlParameter();
SqlParameter pmuserid = new SqlParameter();pmvendorid.ParameterName = "@vendorid";pmvendorid.SqlDbType = SqlDbType.Int;
pmvendorid.Value = vendorid;
pmuserid.ParameterName = "@userid";pmuserid.SqlDbType = SqlDbType.Int;
pmuserid.Value = userid;
cmd.Parameters.Add(pmvendorid);
cmd.Parameters.Add(pmuserid);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
 
}

View 3 Replies View Related

Delet Function Not Working On Gridview

Mar 25, 2007

I 'm having trouble with the delete function on Gridview - the update works great but I keep getting the error below when I try to delete
DELETE statement conflicted with COLUMN REFERENCE constraint 'FK_Order_Details_Products'. The conflict occurred in database 'Northwind', table 'Order Details', column 'ProductID'.The statement has been terminated.
I using the products table in Northwind to learn this stuff.
 
The code that I used is below:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Gigs.aspx.cs" Inherits="Gigs" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
DeleteCommand="DELETE FROM [Products] WHERE [ProductID] = @ProductID" InsertCommand="INSERT INTO [Products] ([ProductName], [SupplierID], [CategoryID], [QuantityPerUnit], [UnitPrice], [UnitsInStock], [UnitsOnOrder], [ReorderLevel], [Discontinued]) VALUES (@ProductName, @SupplierID, @CategoryID, @QuantityPerUnit, @UnitPrice, @UnitsInStock, @UnitsOnOrder, @ReorderLevel, @Discontinued)"
SelectCommand="SELECT * FROM [Products]" UpdateCommand="UPDATE [Products] SET [ProductName] = @ProductName, [SupplierID] = @SupplierID, [CategoryID] = @CategoryID, [QuantityPerUnit] = @QuantityPerUnit, [UnitPrice] = @UnitPrice, [UnitsInStock] = @UnitsInStock, [UnitsOnOrder] = @UnitsOnOrder, [ReorderLevel] = @ReorderLevel, [Discontinued] = @Discontinued WHERE [ProductID] = @ProductID">
<DeleteParameters>
<asp:Parameter Name="ProductID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="ProductName" Type="String" />
<asp:Parameter Name="SupplierID" Type="Int32" />
<asp:Parameter Name="CategoryID" Type="Int32" />
<asp:Parameter Name="QuantityPerUnit" Type="String" />
<asp:Parameter Name="UnitPrice" Type="Decimal" />
<asp:Parameter Name="UnitsInStock" Type="Int16" />
<asp:Parameter Name="UnitsOnOrder" Type="Int16" />
<asp:Parameter Name="ReorderLevel" Type="Int16" />
<asp:Parameter Name="Discontinued" Type="Boolean" />
<asp:Parameter Name="ProductID" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="ProductName" Type="String" />
<asp:Parameter Name="SupplierID" Type="Int32" />
<asp:Parameter Name="CategoryID" Type="Int32" />
<asp:Parameter Name="QuantityPerUnit" Type="String" />
<asp:Parameter Name="UnitPrice" Type="Decimal" />
<asp:Parameter Name="UnitsInStock" Type="Int16" />
<asp:Parameter Name="UnitsOnOrder" Type="Int16" />
<asp:Parameter Name="ReorderLevel" Type="Int16" />
<asp:Parameter Name="Discontinued" Type="Boolean" />
</InsertParameters>
</asp:SqlDataSource>
 
</div>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
CellPadding="4" DataKeyNames="ProductID" DataSourceID="SqlDataSource1" ForeColor="#333333"
GridLines="None">
<FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
<asp:BoundField DataField="ProductID" HeaderText="ProductID" InsertVisible="False"
ReadOnly="True" SortExpression="ProductID" />
<asp:BoundField DataField="ProductName" HeaderText="ProductName" SortExpression="ProductName" />
<asp:BoundField DataField="SupplierID" HeaderText="SupplierID" SortExpression="SupplierID" />
<asp:BoundField DataField="CategoryID" HeaderText="CategoryID" SortExpression="CategoryID" />
<asp:BoundField DataField="QuantityPerUnit" HeaderText="QuantityPerUnit" SortExpression="QuantityPerUnit" />
<asp:BoundField DataField="UnitPrice" HeaderText="UnitPrice" SortExpression="UnitPrice" />
<asp:BoundField DataField="UnitsInStock" HeaderText="UnitsInStock" SortExpression="UnitsInStock" />
<asp:BoundField DataField="UnitsOnOrder" HeaderText="UnitsOnOrder" SortExpression="UnitsOnOrder" />
<asp:BoundField DataField="ReorderLevel" HeaderText="ReorderLevel" SortExpression="ReorderLevel" />
<asp:CheckBoxField DataField="Discontinued" HeaderText="Discontinued" SortExpression="Discontinued" />
</Columns>
<RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
<PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
</form>
</body>
</html>
 Any help would be appreciated - thanx

View 12 Replies View Related

Function Using Comparing Dates Not Working Right

Sep 12, 2006

Hi,

I'm trying to write a function to return all notes with date. Sample data for 1 record=187189 as follows:
iincidentid,iWorkNoteId,iSeqnum, dtEntryDate, workNoteAll
1871893440 1 2006-04-24 note1
1871893545 1 2006-06-22 note2
1871893547 1 2006-06-22 note3
1871893653 1 2006-08-10 note4
1871893653 2 2006-08-10 note5

funtion will return = 2006_08-10 note4 note5 for iincidentid=187189
-----------------------------------------------------
CREATE FUNCTION dbo.getIncidentNotesRev(@iIncidentID int)
RETURNS varchar(8000)
AS
BEGIN
declare @incidentId int
declare @worknoteid int
declare @worknotesaveid int
declare @seqnum int
declare @dtEntryDate smalldatetime
declare @worknoteall varchar(8000)
declare@allnotes varchar(8000)
declare @currentWEDate smalldatetime
declare @beginWEDate smalldatetime

select @allnotes=''
select @currentWEDate=currentweekEndDate from csCurrentweekEndDate --get the current week end date
select @beginWEDate = DATEADD(d, - 28, @currentWEDate)--get the last 4 weeks

declare CursorIncident CURSOR
LOCAL FOR SELECT iIncidentId, iWorkNoteID, iSeqNum, dtEntryDate,worknoteall FROM dbo.rpt_weekly_prospect_status_vw
where iIncidentId=@iIncidentID order by iWorkNoteId

OPEN CursorIncident
FETCH NEXT FROM CursorIncident INTO @incidentId,@worknoteid,@seqnum,@dtEntryDate,@work noteall

--store 1st record of cursor
select @worknotesaveid =@worknoteid
WHILE (@@FETCH_STATUS=0)
BEGIN
if @dtEntryDate >=@beginWEDate AND @dtEntryDate <= @currentWEDate
Begin
if @worknotesaveid <> @worknoteid
Begin
Select @allnotes = @allnotes + @dtEntryDate + @worknoteall
End
else
BEgin
select @allnotes = @allnotes + @worknoteall
End

select @worknotesaveid = @worknoteid --save next worknoteId
End
else
Begin
select @allnotes=''
End
FETCH NEXT FROM CursorIncident INTO @incidentId,@worknoteid,@seqnum,@dtEntryDate,@work noteall
END --WHILE (@@FETCH_STATUS=0)

CLOSE CursorIncident
DEALLOCATE CursorIncident

return @allnotes
END

----------
Function not working right. I appreciate any help.
Thanks in advance.

View 3 Replies View Related

Sql Function Not Working For TEXT Size More Than 8000

Feb 24, 2005

Hi,

I wrote this sql function which takes a comma seperated string of numbers, splits the numbers seperately and stores it in a table. I have specified the input parameter type as text instead of varchar, the size of the string can get more than 8000.

But the function is not working properly if the input size is more than 8000. For example if the input string is of length 8005 and this is the input string from 7995 to 8005 - '123,124,125'. It works fine till 123 and after that it throws an error, Syntax error converting the varchar value '124,125' to a column of data type int. Can anyone tell me what is wrong with this. I am using string functions like charindex, substring. I can post the full function if you want.

Thanks.

View 2 Replies View Related

Stuff Function Not Working With Left Or Right Join

Jan 1, 2015

I found something very strange...stufff function working with self join but not working with left or right join,. I have a table

**Id name**

1 samar

1 Harry

2 jack

I want the output as

**Id name**

1 samar Harry

2 jack

The below query works fine with self join

Select b.id, stuff ((select ` ` + a.name from #test a where a.id = b.id
for xml path (``)),1,1,``)

From #test b
Group by id

But when i do right join i get error _ invalid object name `b`. ....

Select b.id, stuff ((select ` ` + a.name from #test a
right join b on b.id = a.id for xml path (``),1,1,``)

From #test b
Group by id

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved