Query Performence About NText
Sep 5, 2006Is there any difference between a nText field value='' and value=NULL ?
View 4 RepliesIs there any difference between a nText field value='' and value=NULL ?
View 4 Replies
Here each record have start and ending time ,i want to find the timeleft between currenttime and endtime for each and every records.
Eg: This record end within "10day 12hrs 10mins"
suresh writes "Hi
This is suresh,
I want to know some information about Dynamic sql
what its performense wise?
Difference bitween the proc and dynamic sql?
Advantages of dynamic sql?"
i have a single souce table , Table a With contiains records for twodifferent entries for the same vendor by different accountinginstructions,BidId = 10,Person Name=ABC,PersonBidAmt=$100BidId = 11,Person Name=ABC,PersonBidAmt=$110now the recors are to be shown asOriginal Rcds Vs IntutiveRecordsOrName,OrAmt,IntName,IntAmtABC,100,ABC,110for this reason i useSelect A.name,A.Amt,B.name,B.Amtfrom AleftOuterjoin B -- There are many reasons why i do a left outer joinbecause i may not have the record in the b side at allbut this is causing a very big performence issue as this view is veryhuge.31,000 records on each side is taking 2 minits to work.Could any one help me with this.
View 4 Replies View RelatedHello,
I have the following view SQL ( LATESTRECALL_v, for communication purposes ):
SELECT REC.RECKEY, REC.RECSTM, REC.RECUID, REC.RECREC, REC.RECLNN, REC.RECCCD, REC.RECSKU, REC.RECSKD, REC.RECPEC,
REC.RECPRL, REC.RECQTY, REC.RECTGQ, REC.RECTAG, REC.RECASN, REC.RECRLC, REC.RECPLC, REC.RECNTS, REC.RECRST,
REC.RECLOT, REC.RECARF, REC.RECVEN, REC.RECIBO, REC.RECSRN, REC.RECPAR, REC.RECINS, REC.RECSDTR, REC.RECDEA,
REC.RECUOI, REC.RECFPL, REC.RECTDA, REC.RECUMN, REC.RECRQT, REC.RECCID, REC.RECCTN, REC.RECFPC, REC.RECEPU,
REC.RECSCQ, REC.RECLOG, REC.RECSTS, REC.RECTDV, REC.RECSHDR, REC.RECRRN, REC.RECWDF, REC.RECWWF, REC.RECSLT,
REC.RECSQT, REC.RECSTG, REC.RECRTG, REC.RECPSN, REC.RECIFL, REC.RECEXPR, REC.RECMFDR, REC.RECMFGR, REC.RECCNO,
REC.RECSC1, REC.RECSC2, REC.RECSC3, REC.RECSC4, REC.RECSC5, REC.RECSC6, REC.RECSC7, REC.RECSC8, REC.RECSC9,
REC.RECSD1, REC.RECST1, REC.RECSD2, REC.RECST2, REC.RECSD3, REC.RECST3, REC.RECSQ1, REC.RECSQ2, REC.RECSQ3,
REC.RECSQ4, REC.RECSQ5, REC.RECSQ6, REC.RECSDU1, REC.RECSDU2, REC.RECRRC, REC.RECICS, REC.RECJOBS
FROM dbo.REC, dbo.LATESTRECKEY_V
WHERE REC.RECKEY = LATESTRECKEY_V.LATEST_RECKEY
Note that it refers to view LATESTRECKEY_V, which is defined below ( the SQL ):
SELECT REC.RECSKU, REC.RECPRL, max(REC.RECKEY) AS latest_reckey
FROM dbo.REC, dbo.LATESTREC_V
WHERE
REC.RECSKU = LATESTREC_V.RECSKU AND
REC.RECPRL = LATESTREC_V.RECPRL AND
sysdb.ssma_oracle.to_char_date(REC.RECSDTR, 'YYYYMMDD') + REC.RECSTM = LATESTREC_V.LATEST_DATE_TIME
GROUP BY REC.RECSKU, REC.RECPRL
Note that it refers to view LATESTREC_V, which is defined below ( the SQL ):
SELECT REC.RECSKU, REC.RECPRL, max(sysdb.ssma_oracle.to_char_date(REC.RECSDTR, 'YYYYMMDD') + REC.RECSTM) AS latest_date
time
FROM dbo.REC
GROUP BY REC.RECSKU, REC.RECPRL
Now, there already is a key on the REC table, columns RECSKU and RECPRL. Adding that index sped things up quite a bit. But this setup is still very enefficient. I cannot apply the indexed view concept to LATESTRECKEY_V or LATESTREC_V because they use "max". I suppose I could apply it to the first view, but since that view depends on the other 2 views, I am not convinced it will improve my performance. Any ideas on improving such a situation? Thanks for your time.
Tony
I am running this query to an sql server 2000 database from my aspcode:"select * from MyTable whereMySqlServerRemoveStressFunction(MyNtextColumn) = '" &MyAdoRemoveStressFunction(MyString) & "'"The problem is that the replace function doesn't work with the ntextdatatype (so as to replace the stresses with an empty string). I hadto implement the MySqlServerRemoveStressFunction, i.e. a function thattakes a column name as a parameter and returns the text contained inthis column having replaced some letters of the text (the letters withstress). Unfortunately, I could not do that because user-definedfunctions cannot return a value of ntext.So I have the following idea:"select * from MyTable whereCheckIfTheyAreEqualIngoringTheStesses(MyNtextColum n, '" & MyString &"')"How can I implement the CheckIfTheyAreEqualIngoringTheStessesfunction? (I don't know how to combine these functions to do what Iwant: TEXTPTR, UPDATETEXT, WRITETEXT, READTEXT)
View 2 Replies View RelatedI have records in a table as :
Col1 Col2 Col3 Col4
1115090122084511
1119610122084511
How do I query to get records where count(Col4) >1 and Col3 =12
Please note that Col4 is ntext datatype.
TIA,
Andy
I am having some difficulty writing a relatively basic query. The objective is to retrieve the new stories (headlines) for the past 3 days from the database. Since each headline can be assigned multiple categories (topics) the query returns a row for every headline assignment. I can't use the 'Group By' expression because one of the columns is nText.
So basically if there is an article written yesterday, "I Love Cats" that gets assigned both topics 'CATS' and 'PETS' I only it returned with the first topic assigned... 'CATS'. Here is a little image of the three tables being called:
http://64.225.154.232/temp_dbDiagram.gif
I don't think that this query is too difficult, but I'm just getting my feet wet with writing queries that are more than select * from whatever. Any insight or recommendations are greatly appreciated.
SELECT headline.HEADLINE_ID, headline.HEADLINE_TITLE, headline.HEADLINE_DATE, headline.HEADLINE_THUMBNAIL,
topic.TOPIC_NAME, topic.TOPIC_URL
FROM tbl_CCF_Headlines headline INNER JOIN
tbl_CCF_Headlines_Topics ON headline.HEADLINE_ID = tbl_CCF_Headlines_Topics.HEADLINE_ID INNER JOIN
tbl_CCF_Topics topic ON tbl_CCF_Headlines_Topics.TOPIC_ID = topic.TOPIC_ID
WHERE (headline.HEADLINE_DATE IN
(SELECT TOP 3 HEADLINE_DATE
FROM tbl_CCF_HEADLINES
GROUP BY HEADLINE_DATE
ORDER BY HEADLINE_DATE DESC))
ORDER BY headline.HEADLINE_DATE DESC
Hello Guys,Have been getting this error(
Implicit conversion from data type ntext to varchar is not allowed. Use the CONVERT function to run this query.
) when running on the live environment but it was fine when run locally. If anyone has similar problem please let me know the fix you have done.
Thank you.
I wonder if I should do something to the data I store on ntext fields
so far it looks like it has no problem holding special chracters (as it should B for unicode)
anyway - is there some combinations I should avoid ?
Should I use something like on old ASP Server.URLEncode() or Server.HTMLEncode() ?
hi all,
I am new to sql server.
I need some help regarding ntext value.I am using an insert stored proc to insert the value into ntext field, till now i have been using a varchar variable to pass the value. but i think this doesn't work when the size exceeds the limit of varchar and also what if i want to perform group insert?
and the major issue i am concerned about is, i don't want to update this field quite often.I need to check whether the existing ntext value and the new value which i want to insert are different.I want to do it in a better way than processing both values entirely.I want to make sure that the update statement is executed only when both values differ.
HI all,
I Need some help over ntext datatype.one of my table columns is of ntext datatype. how to insert or update this thru storedprocs.
any special notes regarding ntext column.
If I insert 8000 byte of data, in the one of the column. now I want toread the data, is there any to see all the data, through selectstatement?
View 3 Replies View RelatedHi, I'm using a column (ntext) to store some long strings. An example of the string that I need to store is the following:
436;Implementing A Gang - Awareness Program/And A Middle School
Gang Prevention Curriculum. Doctoral Th;Samuels;Donald J;Miami
IV;Administrators; At Risk; Child And Youth Studies; Community;
Community Members; Drop Out Prevention; Educational Leadership;
Law/Criminal Justice; Peer Counseling; Principals; Secondary Education
I wrote a store procedure that does it, but it seems that the column
space is not enough for the above string. The string in fact, is
truncated and only the following portion is stored in my table:
436;Implementing A Gang - Awareness Program/And A Middle School Gang
Prevention Curriculum. Doctoral Th;Samuels;Donald J;Miami
IV;Administrators; At Risk; Child And Youth Studies; Community;
Community Members; Drop Out Prevention; Educational Leadership
What can I do?
Christian
Hi, I have the following problem. I cannot alter column which is ntext under sql server 2000. I get the following error:25-Jul-2007 09:27:11 ERROR [sol.cm.dbsetup.StatementReader] Error occured while executing the statement: Cannot alter column 'asz' because it is 'ntext'. SQLState = S0001 ErrorCode = 492825-Jul-2007 09:27:11 ERROR [sol.cm.dbsetup.StatementReader] SQL statement was: ALTER TABLE a ALTER COLUMN asz NTEXT NOT NULL I cannot use varchar because it is to short. Please tell me if there is a magic way to do this. I've already read in documentation that I cannot alter column which is ntext. Is there really no way to do this. Please help :)
View 3 Replies View Relatedhi
i wants to order by ntext data type.
like
1.1.1.3.1.11.1.1.3.1.11.1.1.3.1.21.1.1.3.1.21.1.1.3.1.31.1.1.3.1.31.1.1.3.1.41.1.1.3.1.41.1.1.3.1.4.11.1.1.3.1.4.11.1.1.3.1.4.101.1.1.3.1.4.101.1.1.3.1.4.111.1.1.3.1.4.111.1.1.3.1.4.121.1.1.3.1.4.121.1.1.3.1.4.131.1.1.3.1.4.131.1.1.3.1.4.141.1.1.3.1.4.141.1.1.3.1.4.151.1.1.3.1.4.151.1.1.3.1.4.161.1.1.3.1.4.161.1.1.3.1.4.21.1.1.3.1.4.21.1.1.3.1.4.31.1.1.3.1.4.31.1.1.3.1.4.41.1.1.3.1.4.41.1.1.3.1.4.51.1.1.3.1.4.51.1.1.3.1.4.61.1.1.3.1.4.61.1.1.3.1.4.71.1.1.3.1.4.7
Thanks
Parth
I am working in asp and using sql server 7. I have a section where the input is to long to use a char field so i had to set the field as ntext. Now i am trying to do a section where i wanna look and see if the field is null and if not then it is to perform an operation. If it is null it is to skip and go to the next field in the record. However it is not performing this operation. It sees the first field and does pass the second one because it is null. If i put in a character into the field it will go on until it gets to a null again and then stops. Any suggestions?
View 2 Replies View RelatedI have come across a column in a database table where the
Data Type = 'ntext'
and the Length = '16'
Does this mean that a maximum of 16 characters can be entered into that column?
Bianca
Hallo. I need help, how pull out some inquiry string from type "ntext" in MS SQL(it is xml document). Sring has invariable length, in note is always on other position and includes variable text (e.g .:<actionId>xx</actionId>) . Position I can find out by the help of "patindex" but I don't know what then. I tryed to write procedures, but I had trouble with declaration variables (data type). Thanks and sorry for my horrible English.
View 6 Replies View RelatedHello All,
Maybe a stupid question but I'm new to the db admin work so please bear with me.
I've imported an Access db into SQL, in the Access db the field type was 'memo' to accomodate the large amount of text (on avg ruffly 4100 chars. with spaces). Now in SQL the field in the table I have set up as an ntext field, which I understood to be equivalent to a memo field in Access.
My problem is when saving data to the field the first time it saves all the data correctly with the exception of the field in question. The data in the field is '<LongText>', now when I try to update the data in the table I get a 'Data Truncated' error message and no update takes place throughout the table.
After testing this and trying different things, I've found that if I shorten this one field and try to save to the db I still get the 'Data Truncated' error message. If I shorten the data in the field AND delete the record from the SQL table then it will save just fine from there on out (which won't work for the reports).
I'm not sure what I'm missing here to get this to work the way it did in Access.
Hi ...
I want define a ntext type variable and set the result of select from ntext field of table in that variable and Execute the variable .
Forexample :
Declare @A ntext
select @A=Fildntext from Table
set @A=@A+'string'
sp_executesql @A
Therefore how can i use ntext type??
thanks
I am new to SQL Server and would like to hear opinions on pros and cons of using nText vs. nVarChar data type for following uses:
URLs (up to 260 bytes)
Addresses (50-300 bytes)
Descriptions and comments (50-2,000 bytes)
Memos (up to 8000 bytes)
TIA.
Hello,
I need to save some news text in an SQL table. The text can be long.
1. Should I use nvarchar(MAX) or nText?
2. And what is the difference between nText and Text?
I am using SQL 2005.
Thanks,
Miguel
Hai, i need ur suggestion to use ntext in my table. basically i want to store the xml data(will be in same xml format only) in sql2000 database. the max size of the data will be 5mb.
so can i use ntext to store this data.basically, only once i insert the data to the database. no update after that. only i throw the query to retrieve that xml data from the database. is it advisable to use,ntext for this requirment. is there any other suggestion ??
help pls
Dear All,
i'm trying to convert the datatype from ntext to nvarchar.i'm getting error. is it not possible?
Vinod
Even you learn 1%, Learn it with 100% confidence.
Hi all,I have an asp page that writes to an ntext field in SQL Server 2000.All was going well until I had to put in a section of text greater than 8000bytes.Then I got a timeout error and the update wouldn't go through.After reading that 2000 only accepts chunks of 8000 bytes or under at atime, I attempted to use the AppendChunk method.The code I wrote seems to work first time I enter text in the page, nomatter how big. But when I try to update the ntext file,if it is more than 8K, it just sits there and nothing happens. Now I donteven get a timeout error.From what I read, I was assured this would work.For small text files under 8K it works beautifully, I can add and removetext and it all works fast.But as soon as the ntext field gets beyond that size its totally unworkable,and seems to be just the same as using the standard UPDATE method. I'veattached the code.If anyone has any suggestions I would be eternally grateful, this is drivingme nuts. I've attached the offending code.ThanksBill' ***********************************************' * PageStatus: SAVE Action: EDIT *' ***********************************************IF PageStatus = "SAVE" AND Action = "EDIT" THENsqlc = "SELECT * from " & tblNameDim FldValDim rsSet rs = Server.CreateObject("ADODB.Recordset")rs.cursortype = 1rs.cursorlocation = 3rs.locktype = 3rs.Open sqlc, oConniChunk = 254cTxtDescription = SQLReady(FileUp.Form(lang))For iNo = 1 to len(cTxtDescription) step iChunkiStartAt = iNocWorkString = mid(cTxtDescription, iStartAt , iChunk )Response.Write "At byte " & iNo & vbCRLF & "<br/>"rs.Fields("SimpleChinese").AppendChunk(cWorkString)NextIF Page_Err = "OK" THEN' Perform the Queryrs.Updaters.CloseSet rs = NothingSet oConn = NothingEND IFEND IF
View 1 Replies View RelatedDear GroupI admit, this might be a very ignorant question.BOL says about the ntext data type:Variable-length Unicode data with a maximum length of 2^30 - 1(1,073,741,823) characters.I've stored a string consisting of around 45.000 characters in a ntextfield - done by copying the string in my txt document and pasting inEnterprise Manager.When I determine the datalength of the field in SQL Analyzer I get2046.Is this realistic? Is it bytes or the actual number of characters? Itseems incrrect to me..Although, when I read the string with a DataReader based on a storedprocedure and save it in a string variable in my VB.NET application,the string is truncated, although the variable can hold up toapproximately 2 billion Unicode characters according to MSDN.I just wonder whether I've done something wrong or misunderstoodsomething on the SQL server side that causes this problem.Thanks very much for your help!Martin
View 2 Replies View RelatedSo, here's the conundrum.
We have ProcA that uses nText as one of it's parameters. It works fine.
I'm writing ProcB, that calls ProcA and also accepts nText as a parameter.
Unfortunately, I have to do a string replace in that nText field. But, I've got that sorted out, with a little UPDATETEXT voodoo.
My input parameter, now exists unchanged as @Body and in #nText.txt with all the modifications completed.
The problem, is I need to pass that #nText.txt value as a parameter to ProcA.
I can't use 'SELECT @Body = txt FROM #nText' because I get an assignment error (can't assign nText values).
And I can't seem to call ProcA with the value from the table directly.
What can I do? I'm 99% there, I just need to take this last step and I can put this garbage behind me.
Thanks
-C
ps SQL2000
Hello!
I'm trying to move from MSDE to SQL Everywhere in my project, which requires using of ADO classic and i have some problems storing ntext data in SQLEv database using parametrized command.
Could it be that the problem is because of ADO classic? Is it ok to use old ADO with SQLEv OLEDB provider and will compatibility with old ADO be maintained in SQLEv?
Below is JScript code illustrating the situation:
-------------------------------
var oConn = new ActiveXObject("ADODB.Connection");
oConn.Open(sConnStr);
var oCmd = new ActiveXObject("ADODB.Command");
oCmd.ActiveConnection = oConn;
var sText = "test text";
oConn.Execute("create table tblTest(sText ntext)");
oCmd.CommandText = "insert into tblTest(sText) values(?)";
oCmd.Parameters(0).Value = sText;
oCmd.Parameters(0).Size = sText.length;
oCmd.Execute();
-------------------------------
It gives me 'Microsoft SQL Server 2005 Everywhere Edition OLE DB Provider: The given type name was unrecognized. [,,,,,]'.
If i remove 'oCmd.Parameters(0).Size = sText.length;' error changes to 'Insufficient memory to complete the operation.'
The same code works ok for MSDE and SQLExpress.
OS:Windowx XP SP2
MDAC version: 2.8
Many thanks!
Is there any way to datamine using ntext? I'm trying to run some BI on some email messages -- seeing if it can accurately classify email into the proper folder. Currently, I get complains that ntext isn't comparable.
Is this scenario supported?
A sql server 2000 table contains a ntext field that needs to be updated. The update is replacing a particular string in the ntext field. I heard it's hard to do it in sql server 2000 itself. Can it be done easily in an SSIS? Please kindly provide example. Thanks.
View 1 Replies View Relatedi define a clumn like this:
clumn name: Body
data type: ntext
then i run a store procedure which is defined as :
create insert_artcle as
(
@body ntext
)
insert into article{body}
values{@body}
but the data get into the database is truncated to 8 charactors
what is the problem? Is it has something to do with the ntext size 16?
In one of my tables, the data type is ntext and if it contains a null value, I get the following error:String[6]: the Size property has an invalid size of 0I'm using vb.net 2005 and sql server 2000.Here's a code snippet of my code behind:
Dim pDescription As SqlParameter = Command.Parameters.Add("@description", SqlDbType.NText)
pDescription.Direction = ParameterDirection.Output
And my stored procedure:
CREATE PROCEDURE dbo.retrieveEquipmentDetails
@idINT,
@assignedIDVARCHAR(50)OUTPUT,
@manufacturerVARCHAR(100)OUTPUT,
@modelNumberVARCHAR(50)OUTPUT,
@serialNumberVARCHAR(50)OUTPUT,
@equipmentTypeVARCHAR(50)OUTPUT,
@descriptionNTEXTOUTPUT,
@locationVARCHAR(50)OUTPUT,
@statusVARCHAR(50)OUTPUT,
@modifiedDateDATETIMEOUTPUT,
@modifiedByINTOUTPUT,
@notesNTEXTOUTPUT,
@calibrationLabIdVARCHAR(255)OUTPUT,
@calibrationRequiredBITOUTPUT,
@calibrationDateDATETIMEOUTPUT,
@calibrationDueDateDATETIMEOUTPUT,
@assetNumberVARCHAR(50)OUTPUT,
--@pictureIMAGEOUTPUT,
@errMessageVARCHAR(256)OUTPUT
AS
BEGIN
DECLARE @errCode INT
DECLARE c_equipment CURSOR FOR
SELECT a.assignedID,
b.Manufacturer,
a.modelNumber,
a.serialNumber,
e.equipmentType,
a.Description,
c.Location,
d.Status,
a.modifiedDate,
a.modifiedBy,
a.Notes,
--a.Picture,
f.LabName,
a.calibrationRequired,
a.calDate,
a.CalDueDate,
a.assetNumber
FROM tblEquipments a,
tblManufacturers b,
tblLocation c,
tblStatus d,
tblEquipment_Type e,
tblLabs f
WHERE a.ID = @id
AND a.manufacturer = b.manufacturerID
AND a.location = c.locationID
AND a.Status = d.statusID
AND a.EquipmentType = e.ID
AND f.ID = a.calLab
FOR READ ONLY
OPEN c_equipment
FETCH NEXT FROM c_equipment INTO @assignedID, @manufacturer, @modelNumber,
@serialNumber, @equipmentType, @description, @location, @status,
@modifiedDate, @modifiedBy, @notes, @calibrationLabId, @calibrationRequired, @calibrationDate,
@calibrationDueDate, @assetNumber--, @picture
IF( @@FETCH_STATUS <> 0 )
BEGIN
SET @errMessage = 'Equipment not found.'
GOTO HANDLE_APPERR
END
CLOSE c_equipment
DEALLOCATE c_equipment
SET @errCode = 0
RETURN @errCode
HANDLE_APPERR:
IF( CURSOR_STATUS( 'local', 'c_equipment' ) >= 0 )
BEGIN
CLOSE c_equipment
DEALLOCATE c_equipment
END
SET @errCode = 1
RETURN
HANDLE_DBERR:
SET @errCode = -1
RETURN
END
GO
So, if anyone has any suggestions, I would like to hear them.And btw, it also happens to the image field (@picture) but I commented it out to try to get the rest working until I'm ready to tackle that one.Thanks,Zath