Trying To CONCAT A TEXT Field With 2 VARCHAR Fields - Brick Wall.

Dec 7, 2006

Hi all. I have been going round and round for the past 2 days on this and would appreciate any help. In a view select statement, I need to concat 2 varchar fields with a text field. If I CONVERT the TEXT field to VARCHAR, only the first 30 characters of the field appear in the result set. If I convert the VARCHAR fields to TEXT, I get an error that I cannot CONCAT TEXT fields. I'm not sure what to do. Can someone please offer some assistance? Thanks in advance! Steve

View 1 Replies


ADVERTISEMENT

Project: Hit Brick Wall

Mar 15, 2008

To ask my question i will create an example.
Table STAFF contains FIRSTNAME and LASTNAME and STAFF_ID.
Table CLASS contains TIME and STAFF_ID

Q: How do i perform a search on CLASS for a specific TIME, and display contents from STAFF, contents being FIRSTNAME AND LASTNAME only. Is it possible since both tables have STAFF_ID in common.

View 4 Replies View Related

Replace Text In Text, Char && Varchar Fields All At Once?

Jan 22, 2008

I have followed many tutorials on selecting and replacing text in text fields, varchar fields and char fields, but I have yet to find a single script that will to all 3 based on field type. Let's assume for a moment that I don't know where all in my database a certain value that I need changed resides ... i.e., the data's tablename and fieldname. How would I go about doing the following ... or more importantly, is this even possible in a SQL only procedure?1) Loop over entire database and get all user tables2) Loop over all user tables and get all fields3) Loop over all fields and determine the field type4) switch between field types and change a string of text from 'a' to 'b'Please be gentle, I'm a procedure newb.

View 9 Replies View Related

Two Int Fields Or One Varchar Field

Jul 20, 2005

I am setting up a database that will receive a lot of data from twoseparate telephone centers, the log table will in a short time haveover 1 million lines, and I was wondering if I should use 1 identifyfield or two:case 1:[Id] [int] IDENTITY (1, 1) NOT NULL[ServerId] [int] NOT NULLcase 2:[Id] [varchar(20)] IDENTITY NOT NULLWhere in case 1 I would just use a combination of Id and ServerId toidentify the line, where in case 2 I would have the Id field a varcharthat would look something like A-000001, A-000002 for server 1 andB-000001, B-000002 for server 2Which solution will be faster when searching for a record when thewill have over 1 million lines?

View 3 Replies View Related

Concatenate Text And Varchar Fields

May 29, 2008

I am trying to add a carriage return to the end of a text field through a script. This is what I'm trying:


UPDATE Table_Name SET Column_TEXT = Column_TEXT) + '

' WHERE Column_TEXT = 'Some text'

I also tried

UPDATE Table_Name SET Column_TEXT = Column_TEXT) + '<cr>' WHERE Column_TEXT = 'Some text'

But I keep getting the error

The data types text and varchar are incompatible in the equal to operator.

Help!!

Thanks in advance
Mangala

View 3 Replies View Related

Optimization Gurus: Help With Varchar Vs. Text Fields Decision

Dec 16, 2007

Hi, I'm trying to improve performance for a db that stores messages.  The message is currently stored in an ntext field, but when I look at all the records from the past 3 months, I found that 88% are less than 1000 characters, and 97% are less than 3000 characters.  I don't want to actually limit the message size, but it seems like I might get much better performance using a varchar(3000) field to hold most of the messages, and a separate text field just used for those 3% that really are long. Is this a good idea?  If so, is it better to put the Message and LongMessage fields in the same table; or, have a separate table to hold the long messages?  If it is in a separate table, it would need to be left joined with the message table each time messages are retrieved.Also -- I am getting about 700 new messages daily, and right now have over 150,000 messages stored.  The vast majority of activity involves new messages.  Is this a good situation to look at using horizontal partitioning?Thanks for any help, I don't really have anyone to discuss this with and it is really helpful to get some other views!! 

View 6 Replies View Related

Can&#39;t Fit Text Field Into Varchar 8000

Aug 16, 2000

I am trying to change a text field into a varchar 8000.
I get his error message when trying to convert.

Unable to modify table.
ODBC error: [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot create a row of size 8317 which is greater than the allowable maximum of 8060.
[Microsoft][ODBC SQL Server Driver][SQL Server]The statement has been terminated.


Anyone know of a way to either truncate the text field or
to select only those that are over the 8000 character mark?

Please advise
Thanks
Susan

View 2 Replies View Related

Max Length For Varchar And Text Field

Feb 2, 2005

Hi, all
I am seting up a table with email message, I am wondering what is the max length for varchar field. I am so reluctant to use text field, since when
I run query for the descriptiona in sql analyzer, text field cannot be fully display in column. Any tricks to share?
Thanks
Betty

View 5 Replies View Related

Encrypt A Text Or Varchar(max) Field

Oct 20, 2005

I understood that sql 2005 has EncryptByCert(varchar) function to encrypt data field. but varchar is limit by 8,000 chars long.

View 3 Replies View Related

How To Concat Varchar In This Case?

Nov 25, 2007

Hi,
I try to create a string that represant a insert statement but I've some problems to concat :

Set @Insert = 'INSERT INTO DEMANDES VALUES (' + @AvionID + ',' + @DemandeID + ',' + @Consommation + ',' + @Vitesse + ',' + @TailleReservoire + ',''' + @PlageHoraireDebut +''','''+ @PLageHoraireFin+''','''+ @VilleDepart+''',''' +@VilleDestination+''');';

AvionID is a int
DemandeID too
Consommation too
Vitesse too,
TailleReservoire too,
PlageHoraire varchar and ville too.

Can you explain me how to concat these strings?

Thanks for your help!

View 5 Replies View Related

VARCHAR And TEXT Field Errors - Limit 255 In 7.0?

Mar 27, 2000

We're connecting to SQL Server 7.0 (sp2) via ODBC for our ASP application, and are having trouble saving information collected in a <textarea> tag on an HTML form. I assume the <textarea> tag contains data of type TEXT. i thought there would be no problem in converting it into a string and saving it in a VARCHAR field in the database. this works fine as long as the string is 255 characters or less. anything over that give me an "Errors Occurred" SQL Server error. the field that i'm saving this into is a VARCHAR length 8000. i thought SQL 7.0 had gotten rid of the 255 limit on varchar - could this be an ODBC driver problem (on my web server i currently have 3.50.0305) and/or should i install service pack 2 on my SQL Server? anyone advice would be much appreciated.

thanks,
matt

View 1 Replies View Related

How To Concate 2 Ore More Text Fields Into One Field?

Oct 12, 2006

Hello,

I hope someone has already done this, but I have a table with a text column- example ColA, now i want to run a query to select the ColA in this table and combine the results of ColA into a ColB in another table.

Something like - Note: the codes below doesn't work!!

DECLARE @ResultID as int
DECLARE @AccID int
DECLARE _rows CURSOR
FOR SELECT AccID FROM tableA

FETCH NEXT FROM _rows INTO @AccID

WHILE (@@fetch_status <> -1)
BEGIN

UPDATE TableB SET Report = Report + (SELECT txtField FROM tableA WHERE AccID = @AccID)

WHERE AccID = @AccID


FETCH NEXT FROM _rows INTO @AccID

END

Thanks in advance



View 8 Replies View Related

Fast Way To Concat Records To Comma Sep VARCHAR

Jul 20, 2005

Hi All,Here's a challenge.If there is a 'one word' answer to this, i.e. the name of a built inSQL Server function I can use, that would be great! However...I have a standard 1:m relationship, e.g. tblHeader and tblDetail.I want to create a view of records from 'tblHeader' and within thatview have a column (called e.g. DetailTypes) that provides a singlecomma separated varchar of values from a varchar field (called e.g.DetailType) that appears in related records in the 'tblDetail' table.(hope you understood that :)e.g. the contents of my 'tblDetail' table could be....Detail ID | Header ID | DetailType-----------------------------------1 | 1 | A2 | 1 | A3 | 1 | B4 | 2 | A5 | 2 | C6 | 3 | BTherefore, the view I want to create should return:Header ID | DetailTypes-------------------------------1 | 2A, 1B2 | 1A, 1C3 | 1Bi.e. the first row can be read as "Header 1 has 2 'A' detail recordsand 1 'B' detail record."I have created a view e.g. 'vqryHeaders' which calls a user definedfunction that takes the HeaderID and opens a cursor on another view,e.g. 'vqryDetailGrouped'. The other view groups the records intblDetail so that I can get a count of each DetailType for each HeaderID. The cursor then loops through the returned records concatenatingthe count and detail type into a comma separated string (as shownabove).However, when I run this across 20k records it is soooo sloooooww. Ihave indexes on the relationship fields and I am using realisticallysized varchars - neither made any difference in speed. It isdefinately the function that I wrote that slows it down as the view islightning fast when I remove my function call.I can supply source code if necessary, but I think that this is akind-of generic problem so I don't see the point - yet.I really hope you can help.Regards,Jezz

View 11 Replies View Related

T-SQL (SS2K8) :: Parsing Text Field Into 4 Fields

Sep 5, 2014

I have a text field that I need to parse out into 4 fields.

30.125x23.625-18.875x25.375
6.1875X19.375-2.4375x15.625
0X0-0x0
26.875X11.375-11.125x22.875
0X0-0x0
0X0-0x0
6.1875X26.875-2.4375x23.125
6.1875X26.875-2.4375x23.125
6.1875X26.875-2.4375x23.125
26.625X14.875-11.125x22.875
26.625X14.875-11.125x22.875

I need to 26.625X14.875-11.125x22.875 should be 26.625 then 14.875 then 11.125 then 22.875

View 5 Replies View Related

Data Truncates When Pasting Text Into Varchar Field (5000)

Jan 10, 2008

I can't paste text (directly into table row via enterprise manager) into a varchar (5000) field, truncates after about 960 char. Length of string trying to paste is about 1400 characters including spaces. No special characters (one apostrophe). Error happens intermittently.

SQL server v2000

View 4 Replies View Related

Executing Sql Code From Text Field Or From Multiple Varchar(8000) Rows In A Table

Jul 20, 2005

Does anyone know of a way to execute sql code from a dynamically builttext field?Before beginning, let me state that I know this db architecture isbuilt solely for frustration and I hope to make it better soon.Unfortunately, there is never a non-crucial time in which we can do anupgrade, so we are stuck for now.Point 1:There are multiple tables: students, courses, cross-referencestudent/courses, teachers, cross-reference teacher/courses, andothers.Point 2:Yearly archiving is done by appending a 2 digit year suffix to thetable and rebuilding the table structure for the current year. Thatis, each of the tables named above has an archive table for 1999,2000, 2001, etc. This leads to many tables and a big mess whenunioning them.Point 3:A history report is run by building a big query that unions each unionof tables (students, courses, etc) by year. This query has grown toobig for a varchar(8000) field. Actually, it's too big for 2 of them.Point 4:I don't want to write code to maintain any more varchar(8000) fieldsfor this query. It should be much more easily handled with atemporary table holding each bit of yearly archive data. I have builtthis and it works fine. I have also figured out how to pull the rowsfrom that table, concatenate them, and insert the resulting lump intoa text field in another table.Point 5:I haven't figured out how to grab the 5 or so records from that tableand execute them on their own. I figured I could grab them, put theminto a text field that's big enough to hold the whole query and thenselect and execute that text field. I've had no luck with that and Ihaven't had any luck finding any references that might help me withthis problem. I keep thinking of nesting execute() calls, but thatdoesn't work.I'm open to questions, potential solutions, hints about different wayto approach the problem, anything.Many thanks in advance,Rick Caborn

View 7 Replies View Related

SQL Server 2008 :: Concatenating Multiple Text Fields Into One Field In Another Table

Oct 7, 2015

SQL code for the following? (SQL Server 2008 R2 - SQL Server 2012).

I have Table1 Containing two fields with the below entries

VehicleType Name

Two Wheels Bicycle
Two Wheels Scooter
Two Wheels Motorcycle
Four Wheels Sedan
Four Wheels SUV
Four Wheels Pickup
Four Wheels Minivan

The result I'm looking for would be

Table2

Vehicle Type
Two Wheels Bicycle, Scooter, Motorcycle
Four Wheels Sedan, SUV, Pickup, Minivan

View 1 Replies View Related

Query, Distinct And Text Concat

Jan 30, 2008

Hi,

I have the following table called "tests" :
id WeekNbrnametest hours
--------------------------------------------------------------------------
1 2007/26John "testA"5
2 2007/26John "testB"6
3 2007/26David "testA"3
4 2007/28David "testC"2
5 2007/30Victor "testD"1

I want to write a query so that I have as a result one row per person and per week, as followed

WeekNbrname testhours
--------------------------------------------------------------------------------
2007/26John"testA, testB" 11
2007/26David"testA" 3
2007/28David"testC" 2
2007/30Victor"testD" 1

This means that I need to concatenate the values of the test column if in the same week and same person.
For now, I have only managed to do the job without the test concatenation the following way:

SELECT DISTINCT WeekNbr, name, SUM(hours) as [Total of hours]
FROM tests
GROUP BY WeekNbr, name

and I get the following:
WeekNbrnamehours
-------------------------------------------------------
2007/26John 11
2007/26David 3
2007/28David 2
2007/30Victor 1


Anyone could help me please?

Thanks so much in advance

Pierrot

View 1 Replies View Related

Importing Of Varchar Field Data In Number Field

Dec 5, 2007

i want to import/copy a varchar field numeric data in to number field pls suggest the solution
one thing more can i convert field type of a table how?


jto it

View 5 Replies View Related

Convert Field From VarChar To Int With Speical Characters In Field

Aug 29, 2007

Hello,

I have a table with a column that is currently a varchar(50), but I want to convert it into an int. When I try to just change the type in design mode I get an error that conversion cannot proceed. When I look at the field it appears some of the entries have special characters appended at the end, I see a box after the value.

How can I remove all speical characters and then convert that field to an int?

Also I tried the following query which did not work as well, same error about conversion.

UPDATE myTable SET field = CAST(field AS int)

View 2 Replies View Related

Adding A Full Text Search Across Multiple Tables (with Text Fields)

Sep 7, 2007

Hi, i'm trying to do a full text search on my site to add a weighting score to my results.  I have the following database structure:
Documents: - DocumentID (int, PK) - Title (varchar) - Content (text) - CategoryID (int, FK)
Categories: - CategoryID (int, PK) - CategoryName (varchar)
I need to create a full text index which searches the Title, Content and CategoryName fields.  I figured since i needed to search the CategoryName field i would create an indexed view.  I tried to execute the following query:
CREATE VIEW vw_DocumentsWITH SCHEMABINDING ASSELECT dbo.Documents.DocumentID, dbo.Documents.Title, dbo.Documents.[Content], dbo.Documents.CategoryID, dbo.Categories.CategoryNameFROM dbo.Categories INNER JOIN dbo.Documents ON dbo.Categories.CategoryID = dbo.Documents.CategoryID
GOCREATE UNIQUE CLUSTERED INDEX vw_DocumentsIndexON vw_Documents(DocumentID)
But this gave me the error:
Cannot create index on view 'dbname.dbo.vw_Documents'. It contains text, ntext, image or xml columns.
I tried converting the Content to a varchar(max) within my view but it still didn't like.
Appreciate if someone can tell me how this can be done as surely what i'm trying to do is not ground breaking.

View 2 Replies View Related

Brick Codes

Jul 20, 2005

Hi,I have a table of Locations around the country. My system produces reportsbased on these Locations. I also have a table containing Brick Codes e.g.Brick Post CodeAB51 AB51AB52 AB52AB55 AB55AB56 AB56AL01 AL1AL02 AL2AL03 AL3AL04 AL4How can I compare the first 3 or 4 letters of the postcode in the Locationstable to the corresponding entry in the Brick Codes table so I can add it tomy report?Thanks for your help

View 2 Replies View Related

Separating One Field Into Two Fields Based On A Character In The Field

Jul 20, 2005

I know there has to be a way to do this, but I've gone brain dead. Thescenario..a varchar field in a table contains a date range (i.e. June 1,2004 - June 15, 2004 or September 1, 2004 - September 30, 2004 or...). Theusers have decided thats a bad way to do this (!) so they want to split thatfield into two new fields. Everything before the space/dash ( -) goes intoa 'FromDate' field, everything after the dash/space goes into the 'ToDate'field. I've played around with STRING commands, but haven't stumbled on ityet. Any help at all would be appreciated! DTS?

View 1 Replies View Related

Parsing Varchar Fields

Sep 24, 2005

What are some good strategic approaches to using freeform text fields fordata that needs to be queried? We have a product whose tables we can'tchange, and I need to count on a "description" field for storing a value.Two, actually. I'm thinking of adopting this convention:InvoiceNumber@VendorAcronymThere'd be a lot of vendors.Additional issue: sometimes these values would be referred to in thedescription field, and I'd need to distinguish them as referrals ratherthan as original recorded instances of the values. For that, I imaginedeither:InvoiceNumber@@VendorAcronymorInvoiceNumber&VendorAcronymInvoiceNumber//VendorAcronymetc. -- something like that.I'm just wondering if there's best practice for doing anything this stupid(hey, I'm stuck with this as our only option just now; hopefully it's onlytemporary). How to parse out whatever I end up implementing -- well, itneeds to be tractable.Thoughts?--Scott

View 21 Replies View Related

HOw To Order Fields Of Type Varchar?

Mar 22, 2000

I have a varchar field which holds IDs like (1, 3, 5, 19, 23) when I order it, i get it ordered in ASCII order like (1, 19, 23, 3, 5) rather than (1, 3, 5, 19, 23) Even if I convert it to int, I won't be able to order it.

is there any way I can order a varchar field numerically?

Angel

View 1 Replies View Related

JDBC - Varchar Or Nvarchar Fields?

May 10, 2006

Hi, I'm starting a new application in java using JTDS jdbc driver(http://jtds.sourceforge.net) and SQLServer 2005 Express.I have to design the database from scratch and my doubt is if I have to usevarchar or nvarchar fields to store string data.Any experience about performance issues using nvarchar instead of varchar(considering that Java internally works in unicode too)?Thanks in advance,Davide.

View 4 Replies View Related

SQL Server/ Text Fields - Cannot Add Free Text

Sep 25, 2007

I have a data table in my project that has a "text" (not varchar) field in it.  I am trying to load this field with little paragraphs of text for showing on my pages. How do I get the free text loaded into the table?  The database explorer and all the data grid controls cut the text off at one line.  There doesn't seem to be any way to get multiline text into this table.  

View 2 Replies View Related

Concatenated Long Varchar Fields Are Getting Truncated

Mar 30, 2004

(I'm using MS SQL 2000)

I've two tables that I've made from some query subsets. Each table has a varchar field with notes/memos and I want to concatenate the fields into one long field.

The problem I'm running into is that when I run the query to check the concatenation, the field is truncated maybe 256 chars in.

I tried converting and casting the field as nvarchar 4000, and I've also done the same for the fields in the two tables, but that doesn't seem to help.

I can query for the fields from each table and none of them are truncated by themselves. It only happens after I concatenate them.

I've created a new table and inserted the results into it, but the field in it is also truncated.

Am I missing something obvious here?

View 2 Replies View Related

T-SQL (SS2K8) :: Copy Varchar (max) Fields Slow

Mar 13, 2015

I'm archiving some data. In a 2 step process.

1. Copy old data from each table in LiveDB to same table in ArchiveDB.
2. Delete the data from each table in LiveDB which is in ArchiveDB

Both DBs SIMPLE recovery mode.

Each table has a clustered PK on a single int value. In both DBs

The tables with varchar(max) columns are taking a v.long time to copy over.

IS there anything I can change in the ArchiveDB to make it run faster.

It is the insert that is taking the time. I've tried dropping the clustered PKs in ArchiveDB tables and then rebuilding afterwards but it has not made any difference. After all I am adding data to the ArchiveDB in clustered index order, so wouldn't have expected it to.

How I can change the Archive DB but cannot touch the schema/settings of Live DB.

View 9 Replies View Related

Dynamic Filedlength Of Varchar Fields In Source

Nov 21, 2006

I'm using SSIS to import data from a table (SQL) containing varchar fields. The problem is, that those varchar fields are changing over time (sometimes shrinking and sometimes expanding). I.e. from varchar(16) to varchar(20).

When I create my SSIS package, the package seem to store information about the length of each source-field. At runtime, if the field-length is larger then what the package expects an error is thown.

Is there anyway around this problem?

Oh, yeah... My destination fields are a lot wider then the source fields, so the problem is not that the varchar values doesn't fit in my destination table, but that the package expects the source to be smaller...

Regards Andreas

View 3 Replies View Related

Retrieving Varchar(max) And Varbinary(max) Fields With VFP9

Mar 20, 2007

I have a test database that contains a varbinary(max) field and a varchar(max) field.

when I do a

Select * from test where id = xx

I get the expected results if my connection string uses

'driver=SQL Server;Server'

but these two fields return no data if I use

'driver=SQL Native Client'

the other fields in the record come back with no problems.

Is there anything special I need to do to retrieve these types of fields?

View 1 Replies View Related

Converting Varchar To Numeric And Date Fields...

Jan 21, 2008



Hi All,

I have 2 varchar fields on MS 2005 table
First field is date and format is 080118(YYMMDD)
and second is salary field like 00002000(positive) and 00002000- (negative)
how can I move them to date and numeric fields on another table....

thanks

View 1 Replies View Related

Transact SQL :: Return Field When A Field Contains Text From Another Field

Aug 25, 2015

I'm new to SQL and I'm trying to write a statement to satisfy the following:

If [Field1] contains text from [Field2] then return [Field3] as [Field4].

I had two tables where there were no matching keys. I did a cross apply and am now trying to parse out the description to build the key.

View 8 Replies View Related







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