Alternative For LEFT() And CHARINDEX() That Works With Text Data Type

Jun 26, 2007

I have a stored procedure that receives a list of ids, to get the emails of each of those ids. The problem that I'm having is that I'm using a char data type that is max length is 8000, but the contact lists are getting bigger and soon they might reach the variable max length. The contact list that I receive will look something like this "1234,67523,67875,789687,", I'm using "," as a separator. Right now what I do is this

@array_value = LEFT(@ContactList, @separator_position - 1)

 

The LEFT function doesn't work with data types text and ntext. But I'm in need of a string data type with a max length bigger than 8000. So I will apreciate if anyone knows of another function that does the same or similar and works with text data type, or any other ideas will be welcome.

 

Thanks,

 Erick

View 8 Replies


ADVERTISEMENT

SQL Server 2008 :: Using Left And Charindex To Parse String / Getting Rid Of Rest Of Data

Jun 16, 2015

I am trying to erase some erroneous bad data in my table. The description column has a lot of </div>oqwiroiweuru</a> weird data attached to it, i want to keep the data to the left of where the </div> erroneous data begins

update MyTable
set Description = LEFT(Description(CHARINDEX('<',Description)-1)) where myid = 1

that totally works.

update MyTable
set Description = LEFT(Description(CHARINDEX('<',Description)-1)) where myid >= 2

gives me a Invalid length parameter passed to the LEFT or SUBSTRING function. The statement has been terminated error.

View 2 Replies View Related

CHARINDEX With INT Data Type (Multiple Value)

Mar 24, 2014

I have a column that has 50 records and they are INT. I am trying to place them into a single parameter using the CHARINDEX using the IF Statement. I got an error saying convertinh from varchar to int type data.

Basically, this is what I did:
@RoomID varchar(max)

Then I declare it:

DECLARE @RoomId varchar(4)

SET @RoomID = 0

The IF part that I need to express this CHARINDEX function.

Then in Where clause I filtered it as:
WHERE r.roomid = @RoomId

Or what other way to handle INT data type and make them available for user to choose multiple value?

View 1 Replies View Related

CharIndex, Left T-SQL Question

Feb 15, 2008

Hello,I was hoping someone could help me with this SQL statement.The column 'options.optionDescrip' is a varchar field.Some values of the 'options.optionDescrip' contain commas, some donot.We are trying to evaluate against any data in the'options.optionDescrip' column located to the left of a comma (if acomma does exist, which it may not). If no comma exists, then we tryand evaluate against the entire field, not just the part to the leftof the comma.SELECT options_optionsGroups.idProduct FROM options_optionsGroupsJOIN Options ON options_optionsGroups.idOption=options.idOptionJOIN products ON options_optionsGroups.idProduct=products.idProduct WHERE (CASE WHEN CharIndex(',',options.optionDescrip) = 0 THENoptions.optionDescrip LIKE '" & gauge & "%' ELSELeft(options.optionDescrip,CharIndex(',',options.o ptionDescrip)) LIKE'" & gauge & "%' END)Thanks for any input you can provide, I appreciate it.

View 1 Replies View Related

SQL Server 2008 :: Left Function And CHARINDEX

Mar 30, 2015

SELECT LEFT(InstanceName,CHARINDEX(' ',InstanceName)-1)
FROM ServerDB

Returns the following error.

Invalid length parameter passed to the SUBSTRING function.

View 2 Replies View Related

How To Return Partial String Using CharIndex And Left In Same Select

Jun 22, 2015

Select
left(
[Description],(charindex(';',[Description],1)-1))
from xxxx

Example of Description contains

Ankle Supports; Color=Black; Size=S

So I want the left side up to and NOT including the semi colon.

View 14 Replies View Related

Converting Numeric Data Type To Text Data Type

Jul 20, 2005

Hi,I would like to convert a dollar amount ($1,500) to represent Fifteenhundred dollars and 00/100 cents only for SQL reporting purposes. Isthis possible and can I incorporate the statement into an existingleft outer join query.Thanks in advance,Gavin

View 1 Replies View Related

Convert Text Data Type To Smalldatetime Data Type

Oct 9, 2007

I have a field that is currently stored as the data type nvarchar(10), and all of the data in this field is in the format mm/dd/yyyy or NULL. I want to convert this field to the smalldatetime data type. Is this possible?
I've tried to use cast in the following way, (rsbirthday is the field name, panelists is the table), but to no avail.


SELECT rsbirthday CAST(rsbirthday AS smalldatetime)

FROM panelists


the error returned is "incorrect syntax near 'rsbirthday'.

I'm rather new to all things SQL, so I only have the vaguest idea of what I'm actually doing.

Thanks for the help!

View 10 Replies View Related

SQL Insert From Text Box Works, But Can't Display Data After

Jan 4, 2008

Ok so I got my insert statement to work properly from multiple text boxes and a button control.  What I'm looking to do is once the customer hits the button and it creates the new row in the table I want to then display the recently created record.  Currently when I hit submit it creates the record, but the screen then goes back to default.  I can then go to another page that I created to browse the records and it sees that the record was created properly.  I would like for the insert to complete and then for the recently created record to be displayed either with a pop up, on the same page, or on a different page that needs to be created.  I've tried tons of different options, but haven't been able to figure it out.  So what I'll do is show you the working code and if you could give me a little help on what code I need to add to accomplish the task.  Thanks.   <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">    <b />    <table style="width:100%;">        <tr>            <td class="style9">                Enter Bug Title:</td>            <td>    <asp:textbox id="bug_title" runat="server" Width="420px" EnableViewState="False"/>                                </td>        </tr>        <tr>            <td class="style9">                Bug Tester:</td>            <td>                <asp:TextBox ID="tester" runat="server" width="420px" EnableViewState="False"/></td>        </tr>        <tr>            <td class="style12">                Description:</td>            <td class="style13">                <asp:TextBox ID="description" runat="server" Width="420px" Height="473px"                     EnableViewState="False" MaxLength="200" TextMode="MultiLine"></asp:TextBox>                                </td>        </tr>        <tr>            <td class="style9">                Severity:</td>            <td>                <asp:DropDownList ID="severity" runat="server" EnableViewState="False">                    <asp:ListItem>Low</asp:ListItem>                    <asp:ListItem>Medium</asp:ListItem>                    <asp:ListItem>High</asp:ListItem>                </asp:DropDownList>            </td>        </tr>        <tr>            <td class="style9">                Project Group:</td>            <td>                <asp:DropDownList ID="project_group" runat="server"                     DataSourceID="ObjectDataSource1" DataTextField="GroupName"                     DataValueField="GroupName" EnableViewState="False">                </asp:DropDownList>                <asp:ObjectDataSource ID="ObjectDataSource1" runat="server"                     OldValuesParameterFormatString="original_{0}" SelectMethod="GetData"                     TypeName="DataSet1TableAdapters.bug_groupsTableAdapter">                </asp:ObjectDataSource>            </td>        </tr>        <tr>            <td class="style9">                &nbsp;</td>            <td>                <asp:button ID="button1" runat="server" text="Submit" OnclientClick="button1_click" />&nbsp;</td>        </tr>    </table> And here is the code behind: Imports System.DataImports System.Data.SqlClientPartial Class Default2    Inherits System.Web.UI.Page    Dim objcon As ConnectionStringSettings = ConfigurationManager.ConnectionStrings("bug_trackerConnectionString")    Dim str As String = objcon.ConnectionString    Dim con As New SqlConnection(Str)    Dim com As New SqlCommand("", con)    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button1.Click        con.Open()        com.Parameters.AddWithValue("@bug_title", bug_title.Text)        com.Parameters.AddWithValue("@tester", tester.Text)        com.Parameters.AddWithValue("@description", description.Text)        com.Parameters.AddWithValue("@project_group", project_group.Text)        com.Parameters.AddWithValue("@severity", severity.Text)        com.CommandText = "INSERT INTO bug_tracker (bug_title, tester, description, severity, project_group) VALUES (@bug_title, @tester, @description, @severity, @project_group)"        com.ExecuteNonQuery()        con.Close()    End Sub 

View 1 Replies View Related

Truncated Text In Text Data Type

Jun 1, 2001

We have a text field which is being written to from a java app through JDBC-ODBC. But the data seems to be trucated in the DB. How do we store all the data in this field (the text being stored can be quite large) without it being truncated?

View 1 Replies View Related

Text Is Getting Cut After 1.4k Letters In Text Data Type

Oct 26, 2007

Hello all,
started working on a website in ASP that use mssql, i am trying to store large ammount of text, for now its just 10kk letters, the data type is set to text in the mssql db, but when i read it back from the db, i only get 7.7k letters, i know its not an ASP problem cause i print the var holding the content before storing it in the db.

my question is, is there a way to change the text length limit in mssql, or use another data type?

Thanks,
Gilad Darshan


EDIT: forgot its saving the html source with the style and not only the words. fixed to the right amount of letters

View 2 Replies View Related

How To Convert To Regular Text, Data Stored In Image Data Type Field ????

Jul 20, 2005

Hi,This is driving me nuts, I have a table that stores notes regarding anoperation in an IMAGE data type field in MS SQL Server 2000.I can read and write no problem using Access using the StrConv function andI can Update the field correctly in T-SQL using:DECLARE @ptrval varbinary(16)SELECT @ptrval = TEXTPTR(BITS_data)FROM mytable_BINARY WHERE ID = 'RB215'WRITETEXT OPERATION_BINARY.BITS @ptrval 'My notes for this operation'However, I just can not seem to be able to convert back to text theinformation once it is stored using T-SQL.My selects keep returning bin data.How to do this! Thanks for your help.SD

View 1 Replies View Related

Move Text Data (not A File) Into An Image Data Type

Mar 11, 2008



The ERP manufacturer used an image data type to store large text data fields. I am trying to move these data types from one database to another database using either Sql Queries or MS Access. I can cast them as an 8000 char varchar to read them directly but have no luck importing into these image data fields.

Access and Crystal are not able to read these fields directly.

Any suggestions? Most information about these fields has to do with loading files but I am just moving data.

Thanks,

Ray

View 1 Replies View Related

SQL Server 2012 :: Using Lookup As Alternative In SCD Type 2 And Adding Date?

Apr 26, 2014

how i can add date using ssis or data tools 2012..My flat files had no date..den my instructor gave us a database where it has recordstartdate, recordenddate and currentdate.how i suppose to add date?

tell me the steps to how to do it?

View 2 Replies View Related

Text Data Type

Aug 30, 2005

This is a newbie question.
How many character does a text data type of MSSQL can contain ?
Thanks a lot.

View 2 Replies View Related

Text Data Type

Jun 17, 2002

Hi All,
In the SQL Server documentation, it is said that, the text data type will contain upto 2GB size. I assumed it will save upto 2GB. But what happened is, it saves only 255 characters all others were truncated. Is there anything wrong with me? Or the wrong is with the SQL Server?

Thanks,
Amjath

View 2 Replies View Related

Text Data Type

Mar 17, 2007

visual studio 2005 what is the differences between text, varchar and nvarchar data types in ms sql server? when and when not to use them?

View 4 Replies View Related

Text Data Type

Mar 23, 2008

I'm having a bit of a problem with this data type. It is supposed to be able to store about 2,147,483,647 characters, but when I enter more than about 1,834 characters no more charaters can be stored.

Has anyone experienced this and knows how to allow up to the 2,147,483,647 characters. Is it anything to do with another SQL Server setting or variable that needs to be changed

Thank you in advance for helping on this.

Regards

Steve Fouracre

Steve Fouracre

View 4 Replies View Related

Why Does Data Type Text Allow Max. 64 Characters?

Dec 25, 2006

hi all
does anybody know why the fields of my db with the type "text" can store max. 64 characters? i thought fields of the type "text" could save unlimited characters. is it any wrong setting?i'm using visual web developer with sql server express

View 2 Replies View Related

Data Type Varchar And Text

Oct 27, 2007

I encounter this particular error.
Exception Details: System.Data.SqlClient.SqlException: The data types varchar and text are incompatible in the equal to operator.
Line 21:             Dim reader As SqlDataReader = command.ExecuteReader() 
This is the first time I'm trying out with MS SQL so I'm abit lost. I hope my code is correct and I've did a little search. I did not set "Text" in my database, I use int and varchar. Here's the affected part of my code and the database. Dim password As String = ""
Dim querystring As String = "SELECT Password FROM Member WHERE Username = @username"

'Dim conn as SqlConnection
Using conn As New SqlConnection(ConfigurationManager.ConnectionStrings("mainconnect").ConnectionString)
Dim command As New SqlCommand(querystring, conn)
command.Parameters.Add("@username", SqlDbType.Text)
command.Parameters("@username").Value = txtLogin.Text
conn.Open()

Dim reader As SqlDataReader = command.ExecuteReader()
While reader.Read()
password = reader("Password").ToString()
End While

reader.Close()

End Using
 
My database:
User_ID int(4)
Username varchar(50)
Password varchar(255)
Email varchar(50)
 
Any ideas?

View 2 Replies View Related

TEXT Data Type In SQL Server

Aug 20, 2004

Sorry if this is a dumb question.

I have a SQL Server TEXT Data Type field which stores a long description.
However when I update it from C# (ASP.net) through a textbox, it seems to cut off a part of the data if the number of characters is a big size (+- more than 577 characters).

I pass the data from then textbox to a string, but as soon as I run the Create/Update stored procedure that gets passed the string field, it seems to chop off the string.

What am I doing wrong?
Should one rather use a SQL Server string field for descriptions (+-1000 characters long) or should one use the TEXT field for this purpose?

Which one's performance is better?

View 1 Replies View Related

Text Data Type And Performance

Dec 13, 2005

I was wondering if someone could clear this up for me...
I have a table that will be used to store information about products that I will be selling on a new website. I would like to store each product in a table which will include a description of around 1000 words. I was deliberating over whether to store this chunk of text in a column with the data type set as 'text', or to store the text in a seperate txt file on the server. The search facility on the site will not be required to query this text so which would offer the best in terms of performance?

View 3 Replies View Related

Using Group By For Text Data Type

May 22, 2006

Hi,I have a problem on an old app. This application is a Help Desk, any Computer related problem (Motherboard Burn Out, Software Crash, dll) on my company will be recorded using this Help Desk application.One month ago, some programmer found a bug in this program lead to many duplicate data on database. But too late, This program has entered production stage and used for more than 2 years. This bug only happen at some condition so I found out after 2 years running (when my boss reported there are some duplicate data on "helpDesk" table).The bug is solved but helpDesk table need some "cleaning" operation. Here is structure of that table :helpDesk Table- id (primary key, integer auto increment)- reported_by (varchar 200)- problem_title (varchar 200)- problem_description (text)- date_summited (datetime)well usualy if I want to find some duplicate data I wil type :SELECT     MAX(uid) AS uid, reported_by, problem_title, COUNT(uid) AS total_duplicateFROM         problemsGROUP BY problem_title, problem_description,uidHAVING      (COUNT(uid) > 1)But that query will not work because problem_description data type is "text" which not support "group by" statement.Any other Idea how to locate and cleaning up this duplicate data?thanks

View 2 Replies View Related

Data Type For MP3&#39;s And Long Text

Jul 11, 2001

Hello,
I would like to know as to what data type is the best if I want to store MP3's and large amount of text in a SQL server.
Please let me know about the data type for both the tasks.
The table for MP3 is different than the table for large text (eg . saving somebody's resume)
Please do let me know.

Thank you,

John

View 2 Replies View Related

Trigger And Text Data Type

Dec 6, 2000

Hi All,
I have the code below on Sql 2k table with the column Descriptivetext defined as
Text Data Type. The table has Path and Page as the PK
I need to set a trigger to update Desciptivetext in other rows with the same path
when a one of them chnages.
Whenever I run the code, no row is updated

CREATE TABLE [dbo].[AB] (
[PATH] [varchar] (255) NOT NULL PRIMARY KEY CLUSTERED ,
[PAGE] [varchar] (60) NOT NULL PRIMARY KEY CLUSTERED ,
[DESCRIPTIVETEXT] [text] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

CREATE TRIGGER [Update_Staging_Test] ON [dbo].[AB]
INSTEAD OF UPDATE
AS

Declare @TextPointer as Varbinary (16), @NewTextPointer as Varbinary (16), @Path
varchar(255), @Page as varchar(60), @DescriptiveText as varchar(7000)
If Update(DescriptiveText)
--Get the Path of the record from Inserted
Select @Page = Page, @Path = Path , @DescriptiveText = Cast(DescriptiveText as
Varchar(7000))
from Inserted


UPDATEAB
SETDescriptiveText = Cast (@DescriptiveText as Text)
WHEREPath = @Path




Rgds
GERI

View 5 Replies View Related

Text Data Type In Trigger

Feb 22, 2007

Hi,

I am using following query to get insereted records from a table, which is containing a column, having text datatype.

'SELECT * INTO #TEMP FROM INSERTED'

Then obviously it gives error.

Wat if i want to get all the columns from inserted table excluding the text datatype column, without giving the column names.

Thanks & Regards.
Shabber.

View 1 Replies View Related

Problem With Using A 'text' Data Type.

May 18, 2004

I am using a 'text' data type in a table and am having trouble adding data to it. I'm using an MS Access ADP project front end for my forms. I want to copy and paste from a text editor such as NotePad to a 'text' data type field in a form. There appears to be a limit that the field will accept which is much below the 2GB size that is allowed for the field. I get the following error message: "The text is too long to be edited." Once I get this error I can add characters from the keyboard but eventually the field will not accept any more characters. Typing or pasting does nothing. I can delete. So I've hit a limit but I'm not sure if it is in Access or SQL Server.

Any help would be appreciated.

Dennis Geasan

View 2 Replies View Related

Text Data Type Problem

Oct 12, 2007

I have a table named 'Documents' with a field named 'DocumentData' which is of the datatype Text.

I am using the following statements in a stored procedure which on execution gives errors:


DECLARE @DocData VARCHAR(100)

DECLARE @OrderID INT

IF ISNULL(@DocData, '') <> ''

BEGIN



IF EXISTS( SELECT DocumentData from Documents where OrderID=@OrderID and DocumentData = @DocData)

RaisError ('Document ignored.', 16, 1)






The errors that i am getting are the following :

Msg 279, Level 16, State 3, Procedure SPDocs_LoadData, Line 41
The text, ntext, and image data types are invalid in this subquery or aggregate expression.
Msg 306, Level 16, State 1, Procedure SPDocs_LoadData, Line 41
The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.

Can anyone tell me how to rectify this? Basically i am trying to find out whether @DocData passed in the stored procedure matches the value in the table.

Thanks.

View 6 Replies View Related

SQL Server 'text' Data Type. Why Is Length = 16??

May 23, 2004

i need to store quite along description in the database, which in anyother database i would choose the data type 'text', however, can someone tell me why the length is set to just 16 in sql server..... i have seen a text field with far greater than 16 chars, set at length 16, so what does this length of 16 mean?????
also what is the max length of the text field?

thanks

View 2 Replies View Related

Using Text Data Type In Dynamic Sql Sproc

Jul 20, 2005

hi allthis is my first post to this group, so pls bear with me while i tryto make some sense.i am trying to create a sproc which uses dynamic sql to target aparticuar table eg. '[dbo].[' + @tableID + '_articles']' and performsome actions.i am using @tableID [int] as a passes parameter for the sproc.everything seems to work fine until i try and manipulate a parameterwhich is of text data type.the error occurs when i try to build the dynamic sql string and appendthe text type variable.eg.CREATE PROCEDURE [procArticlesInsert](@siteID [int],@strShortTitle [varchar](40),@strLongTitle [varchar](60),@strShortContent [text],@strLongContent [text],@intSectionID [int],@intTemplateID [int],@intStatusID [int])ASDECLARE @strSQL varchar (1000)DECLARE @strSiteID varchar (10)SET @strSiteID = CAST(@siteID AS varchar)SET @strSQL = ('INSERT INTO [' + @strSiteID + '_articles] ' +'( [dateEntered], ' +'[shortTitle], ' +'[longTitle], ' +'[shortContent], ' +'[longContent], ' +'[sectionID], ' +'[templateID], ' +'[statusID]) ' +'VALUES ' +'(' + CAST(GETDATE() AS VARCHAR) + ', ' +'''' + @strShortTitle + ''', ' +'''' + @strLongTitle + ''', ' +''''@strShortContent , ' +'@strLongContent , ' +CAST(@intSectionID AS VARCHAR) + ', ' +CAST(@intTemplateID AS VARCHAR) + ', ' +CAST(@intStatusID AS VARCHAR) + ')')GOi could cast the text fields (@strShortContent , @strLongContent) tovarchar, but the restriction of 8000 characters will not go down sonicely.if anyone has any ideas or alternatives to what i am trying toachieve, i would love to hear from you.thanksadrian.

View 5 Replies View Related

Breaking Out Data From A Text Field Type

Jul 20, 2005

In my database there is a text field type that is used to enter streetaddress. This address could be a few lines long, each line with acarriage return at the end.Is there a way to search for these carriage returns and break out whatis in each line seperately?Thanks.Mike

View 1 Replies View Related

Using TEXT Data Type With Carriage Return

Jul 29, 2007

Hi,

I'm using quite odd combination of technology for my project, I'm using PHP and MSSQL 2000, at one certain page, I want to insert to a table where one of the column is TEXT data type, and I want to get the value from the TEXTAREA at the page, of course, with carriage return captured, I manage to get it done in MySQL, where it automatically store the carriage return keyed in by user at the TEXTAREA, while for MSSQL I no luck in finding solution for this, is there any settings I can set or I need to convert the carriage return keystroke to HTML tag at my PHP?

Thanks

View 1 Replies View Related

Inserting The Data Into Text Data Type

Jan 22, 2001

Hi everybody,

In our datbase we have a table with text data type.Help me if anybody knows how to insert text data into text data type of sql server.

i am able to modify and retrive but i am not able to insert text. please if u have idea, please give me reply asap.

Thanks,
Giri

View 1 Replies View Related







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