Search Results

Search found 1805 results on 73 pages for 'varchar'.

Page 4/73 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • what's the performance difference between int and varchar for primary keys

    - by user568576
    I need to create a primary key scheme for a system that will need peer to peer replication. So I'm planning to combine a unique system ID and a sequential number in some way to come up with unique ID's. I want to make sure I'll never run out of ID's, so I'm thinking about using a varchar field, since I could always add another character if I start running out. But I've read that integers are better optimized for this. So I have some questions... 1) Are integers really better optimized? And if they are, how much of a performance difference is there between varchars and integers? I'm going to use firebird for now. But I may switch later. Or possibly support multiple db's. So I'm looking for generalizations, if that's possible. 2) If integers are significantly better optimized, why is that? And is it likely that varchars will catch up in the future, so eventually it won't matter anyway? My varchar keys won't have any meaning, except for the unique system ID part. But I may want to obscure that somehow. Also, I plan to efficiently use all the bits of each character. I don't, for example, plan to code the integer 123 as the character string "123". So I don't think varchars will require more space than integers.

    Read the article

  • Postgre varchar field between

    - by Anton
    I have an addresses table with ZIP code field which has type VARCHAR. I need to select all addresses form this table using ZIP codes range. If I used next code: select * from address where cast(zip as bigint) between 90210 and 90220 I get an error on fields where ZIP code cann't be cast as bigint. How I can resolve this issue?

    Read the article

  • SQL Joins on varchar fields timing out

    - by CL4NCY
    Hi, I have a join which deletes rows that match another table but the joining fields have to be a large varchar (250 chars). I know this isn't ideal but I can't think of a better way. Here's my query: DELETE P FROM dbo.FeedPhotos AS P INNER JOIN dbo.ListingPhotos AS P1 ON P.photo = P1.feedImage INNER JOIN dbo.Listings AS L ON P.accountID = L.accountID WHERE P.feedID = @feedID This query is constantly timing out even though there are less than 1000 rows in the ListingPhotos table. Any help would be appreciated.

    Read the article

  • Error with varchar(max) column when using net.sourceforge.jtds.jdbc.Driver

    - by Rihan Meij
    Hi I have a MS SQL database running (MS SQL 2005) and am connecting to it via the net.sourceforge.jtds.jdbc.Driver. The query works fine for all the columns except one that is a varchar(max). Any ideas how to get around this issues? I am using the jdbc driver to run a data index into a SOLR implementation. (I do not control the database, so the first prize solution would be where I can tweak the SQL command to get the desired results) Thanks

    Read the article

  • Auto generate varchar Ticket number via DB...

    - by Rusty
    Hello, I'm looking for suggestion on how to get the DB to auto generate Ticket numbers (preferably via the SQL DB) for a varchar column. I have the following tables in the DB: Activities & Cases and would prefer the format to be "Act000001" or "Cse000001". This would be something similar to the identity column property. Any suggestion would be highly appreciated. Thanks. Rusty

    Read the article

  • In SQL server, to convert a varchar which have this format (nnn:nn:nn)

    - by user1688917
    I have this varchar format as time accumulation and i want to convert it to an integer to do a SUM and get the total time for a group. The fist part which may be 1, 2, 3, 4 or even five digits represent the accumulation of Hours and then seperated by a colon. then come the second part which is accumulation of minutes and last accumulation of seconds (2 digits each). How to convert this to integer in one query if possile.

    Read the article

  • Helping linqtosql datacontext use implicit conversion between varchar column in the database and tab

    - by user213256
    I am creating an mssql database table, "Orders", that will contain a varchar(50) field, "Value" containing a string that represents a slightly complex data type, "OrderValue". I am using a linqtosql datacontext class, which automatically types the "Value" column as a string. I gave the "OrderValue" class implicit conversion operators to and from a string, so I can easily use implicit conversion with the linqtosql classes like this: // get an order from the orders table MyDataContext db = new MyDataContext(); Order order = db.Orders(o => o.id == 1); // use implicit converstion to turn the string representation of the order // value into the complex data type. OrderValue value = order.Value; // adjust one of the fields in the complex data type value.Shipping += 10; // use implicit conversion to store the string representation of the complex // data type back in the linqtosql order object order.Value = value; // save changes db.SubmitChanges(); However, I would really like to be able to tell the linqtosql class to type this field as "OrderValue" rather than as "string". Then I would be able to avoid complex code and re-write the above as: // get an order from the orders table MyDataContext db = new MyDataContext(); Order order = db.Orders(o => o.id == 1); // The Value field is already typed as the "OrderValue" type rather than as string. // When a string value was read from the database table, it was implicity converted // to "OrderValue" type. order.Value.Shipping += 10; // save changes db.SubmitChanges(); In order to achieve this desired goal, I looked at the datacontext designer and selected the "Value" field of the "Order" table. Then, in properties, I changed "Type" to "global::MyApplication.OrderValue". The "Server Data Type" property was left as "VarChar(50) NOT NULL" The project built without errors. However, when reading from the database table, I was presented with the following error message: Could not convert from type 'System.String' to type 'MyApplication.OrderValue'. at System.Data.Linq.DBConvert.ChangeType(Object value, Type type) at Read_Order(ObjectMaterializer1 ) at System.Data.Linq.SqlClient.ObjectReaderCompiler.ObjectReader2.MoveNext() at System.Linq.Buffer1..ctor(IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source) at Example.OrdersProvider.GetOrders() at ... etc From the stack trace, I believe this error is happening while reading the data from the table. When presented with converting a string to my custom data type, even though the implicit conversion operators are present, the DBConvert class gets confused and throws an error. Is there anything I can do to help it not get confused and do the implicit conversion? Thanks in advance, and apologies if I have posted in the wrong forum. cheers / Ben

    Read the article

  • Mssql varchar to datetime

    - by Dezigo
    I have a field varchar(14) = 20090226115644 I need convert it to - 2009-02-26 11:56:44 (datetime format) My idea. use cast and convert.. but I allways have errors. Conversion failed when converting datetime from character string. I made this, but don`t like it.. SELECT SUBSTRING(move,1,4) + '-' + SUBSTRING(move,5,2) + '-' + SUBSTRING(move,7,2) + ' ' + SUBSTRING(move,9,2) + ':' + SUBSTRING(move,11,2) + ':'+SUBSTRING(move,13,2) as new -- FROM [Test].[dbo].[container_events] where move IS not null Result :2009-02-26 11:56:44

    Read the article

  • SQL Server varchar to datetime

    - by Dezigo
    I have a field varchar(14) = 20090226115644 I need convert it to - 2009-02-26 11:56:44 (datetime format) My idea. use cast and convert.. but I always have errors. Conversion failed when converting datetime from character string. I made this, but don`t like it.. SELECT SUBSTRING(move,1,4) + '-' + SUBSTRING(move,5,2) + '-' + SUBSTRING(move,7,2) + ' ' + SUBSTRING(move,9,2) + ':' + SUBSTRING(move,11,2) + ':'+SUBSTRING(move,13,2) as new -- FROM [Test].[dbo].[container_events] where move IS not null Result :2009-02-26 11:56:44

    Read the article

  • mySQL convert varchar to date

    - by Jeff V
    I need to convert a varchar value of 1/9/2011 to a date in mySQL and I want only the month and year. So that I can then use the PERIOD_DIFF function (so I would need the above to be converted to 201101). I've tried various ways using the STR_TO_DATE function: SELECT STR_TO_DATE(CYOApp_oilChangedDate, '%m/%Y') FROM CYO_AppInfo But I get weird results... (for example: 2009-01-00) What am I doing incorrectly?

    Read the article

  • Checkbox values to varchar via Spring

    - by iowatiger08
    I am trying to get a varchar message from a database to display the selected values of a checkbox field in a jsp for patient's medication's dosage frequency. The possible values will be saved in comma-delimited string in the varchar. For most form fields there is simply a one form value to one database field ratio, but in this case, I am needing to merge the values that would come as a string[] into the comma-delimited string and then when retrieving that record for that medication of that patient, display the selected values from the comma-delimited string as selected from the selectableDosageFrequencyList. You assistance in this is greatly appreciated as I am not sure what I am missing here. In the application context, I created the list of possible values as part of the ServiceBean. <property name="selectableDosageFrequencyList"> <set> <value>On an empty stomach</value> <value>Every other day</value> <value>4 times daily</value> <value>3 times daily</value> <value>Twice daily</value> <value>At bedtime</value> <value>With meal</value> <value>As needed</value> <value>Once daily</value> </set> </property> This is set up in the flow as requestscope. <view-state id="addEditMedication" model="medication"> <on-render> <set name="requestScope.selectableDosageFrequencyList" value="memberService.buildSelectableDosageFrequencyList(patient)" /> </on-render> ... <transition on="next" to="assessment" > <evaluate expression="memberService.updateMedication(patient, medication)" /> </transition> </view-state> I have helper methods in the memberService that need to be executed when the form is init and then when the form is completed. //get the form fields selected and build the new string for db public String setSelectedDosageFrequency(String [] dosageFrequencies){ String frequencies = null; if (dosageFrequencies != null){ for (String s : dosageFrequencies){ frequencies = frequencies + "," + s; } } return frequencies; } //get value from database and build selected Set public LinkedHashSet<String> getSelectedDosageFrequencyList(String dosageFrequency){ String copyOfDosages =dosageFrequency;//may not need to do this LinkedHashSet<String> setofSelectedDosageFrequency = new LinkedHashSet<String> (); while (copyOfDosages!= null && copyOfDosages.length()>0){ for (String aFrequency: selectableDosageFrequencyList){ if (copyOfDosages.contains(aFrequency)){ setofSelectedDosageFrequency.add(aFrequency); if (!copyOfDosages.equals(aFrequency) && copyOfDosages.endsWith(aFrequency)){ copyOfDosages.replaceAll(","+aFrequency, ""); }else if (!copyOfDosages.equals(aFrequency) && copyOfDosages.contains(aFrequency=",")){ copyOfDosages.replaceAll(aFrequency+",", ""); }else copyOfDosages.replaceAll(aFrequency, ""); copyOfDosages.trim(); } } } return setofSelectedDosageFrequency; } The Medication class that backs the form will have a variable for dosage-frequency as a string. private String dosageFrequency; The jsp I currently am doing this. <div class="formField"> <form:label path="dosageFrequency">Dosage Frequency</form:label> <ul class="multi-column double" style="width: 550px;"> <form:checkboxes path="dosageFrequency" items="${selectableDosageFrequencyList}" itemLabel="${selectableDosageFrequencyList}" element="li" /> </ul> </div>

    Read the article

  • Can django's auth_user.username be varchar(75)?

    - by perrierism
    Django's auth_user.username field is 30 characters. That means you can't have auth_user.username store an email address. If you want to have users authenticate based on their email address it would seem you have to do some wonky stuff like writing your own authentication backend which authenticates based on (email, password) instead of (username, password) and furthermore, figuring out what you're going to put in the username field since it is required and it is a primary key. Do you put a hash in there, do you try to put the id in there... bleh! Why should you have to write all this code and consider edge cases simply because username is too small for your (farily common) purposes? Is there anything wrong with running alter table on auth_user to make username be varchar(75) so it can fit an email? What does that break if anything?

    Read the article

  • conversion of a varchar to a smalldatetime results in an out-of-range value

    - by michael
    The code: strSql = "insert into table2 (transactiondate) values ('" & transactiondate & "')" seems to be giving me the runtime error: The conversion of a varchar data type to a smalldatetime data type resulted in an out-of-range value In the code, strSql is a String object and transactiondate is a Date object. In the SQL database however, transactiondate is a smalldatetime object. I've tried changing the smalldatetime to a datetime (in the database) and I've tried transactiondate.toString() but with no success. How can this be fixed? Note: I know about the dangers of inline SQL. I am looking for a quick fix solution here and not a discussion about SQL injection.

    Read the article

  • #1366 - Incorrect integer value:MYsql

    - by rajanikant
    hi every one i have a problem in mysql my table is CREATE TABLE IF NOT EXISTS `contactform` ( `contact_id` int(11) NOT NULL AUTO_INCREMENT, `first_name` varchar(50) NOT NULL, `addition` varchar(50) NOT NULL, `surname` varchar(50) NOT NULL, `Address` varchar(200) NOT NULL, `postalcode` varchar(20) NOT NULL, `city` varchar(50) NOT NULL, `phone` varchar(20) NOT NULL, `emailaddress` varchar(30) NOT NULL, `dob` varchar(50) NOT NULL, `howtoknow` varchar(50) NOT NULL, `othersource` varchar(50) NOT NULL, `orientationsession` varchar(20) NOT NULL, `othersession` varchar(20) NOT NULL, `organisation` int(11) NOT NULL, `newsletter` int(2) NOT NULL, `iscomplete` int(11) NOT NULL, `registrationdate` date NOT NULL, PRIMARY KEY (`contact_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=39 ; mysql>insert into contactform values('','abhi','sir','shukla','vbxcvb','342342','asdfasd','234234234','[email protected]','1999/5/16','via vrienden of familie','','19','20','6','1','1','2010-03-29') i get following error. #1366 - Incorrect integer value: '' for column 'contact_id' at row 1 this query work fine on my local machine but give error on server

    Read the article

  • PostgreSQL 8.3 data types: xml vs varchar

    - by Sejanus
    There's xml data type in Postgres, I never used it before so I'd like to hear opinions. Downsides and upsides vs using regular varchar (or Text) column to store xml. The text I'm going to store is xml, well-formed, UTF-8. No need to search by it (I've read searching by xml is slow). This XML actually is data prepared for PDF generation with Apache FOP. XML can be generated dynamically from data found elsewhere (other Postgres tables), it's stored as is only so that I won't need to generate it twice. Kinda backup#2 for already generated PDF documents. Anything else to know? Good practices, performance, maintenance, etc?

    Read the article

  • SQL indexing on varchar

    - by alex
    I have a table whose columns are varchar(50) and a float - I need to (very quickly) look get the float associated with a given string. Even with indexing, this is rather slow. I know, however, that each string is associated with an integer, which I know at the time of lookup, so that each string maps to a unique integer, but each integer does not map to a unique string. One might think of it as a tree structure. Is there anything to be gained by adding this integer to the table, indexing on it, and using a query like SELECT floatval FROM mytable WHERE phrase=givenstring AND assoc=givenint? This is Postgres, and if you couldn't tell, I have very little experience with databases.

    Read the article

  • schema for storing different varchar fields over time?

    - by Henry
    This app I'm working on needs to store some meta data fields about an entity. The problem is that we can already foresee that these fields are going to change a lot in the future. I'm using Hibernate (in ColdFusion) and each entity's properties are translated to one column in the entity table, but altering table columns later down the raod will be costly and error-prone right? Should I go for something like this? MetaDataField ----- metaDataFieldID (PK), name FieldValue ---------- EntityID (PK, FK), metaDataFieldID (PK, FK), value [varchar(255)] Is this common? Anything to watch out for? p.s. I also thought of using XML on SQL Server 05+. After talking to some ppl, seems like it is not a viable solution 'cause it will be too slow for doing certain query for reporting purposes.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >