Search Results

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

Page 34/73 | < Previous Page | 30 31 32 33 34 35 36 37 38 39 40 41  | Next Page >

  • String update in SQL Server

    - by Thiyaneshwaran S
    Currently I have varchar field. The delimiter is "$P$P$". The delimiter will appear at least once and at most twice in the varchar data. Eg. Sample Heading$P$P$Sample description$P$P$Sample conclusion Sample Heading$P$P$Sample Description If the delimiter appears twice, I need to insert a text before the second occurance of the delimiter. Eg: Sample Heading$P$P$Sample DescriptionINSERT TEXT HERE$P$P$Sample Conclusion If the delimiter occurs only once, then I need to insert a text at the end of the field. Eg: Sample Heading$P$P$Sample DescriptionAPPEND TEXT HERE How this can be done in SQL query?

    Read the article

  • how to use oracle package to get rid of Global Temp table

    - by john
    I have a sample query like below: INSERT INTO my_gtt_1 (fname, lname) (select fname, lname from users) In my effort to getting rid of temporary tables I created a package: create or replace package fname_lname AS Type fname_lname_rec_type is record ( fname varchar(10), lname varchar(10) ); fname_lname_rec fname_lname_rec_type Type fname_lname_tbl_type is table of fname_lname_rec_type; function fname_lname_func ( v_fnam in varchar2, v_lname in varchar2 )return fname_lname_tbl_type pipelined; being new to oracle...creating this package took a long time. but now I can not figure out how to get rid of the my_gtt_1 how can i say... INSERT INTO <newly created package> (select fnma, name from users)

    Read the article

  • SQL Server concurrency and generated sequence

    - by Goyuix
    I need a sequence of numbers for an application, and I am hoping to leverage the abilities of SQL Server to do it. I have created the following table and procedure (in SQL Server 2005): CREATE TABLE sequences ( seq_name varchar(50) NOT NULL, seq_value int NOT NULL ) CREATE PROCEDURE nextval @seq_name varchar(50) AS BEGIN DECLARE @seq_value INT SET @seq_value = -1 UPDATE sequences SET @seq_value = seq_value = seq_value + 1 WHERE seq_name = @seq_name RETURN @seq_value END I am a little concerned that without locking the table/row another request could happen concurrently and end up returning the same number to another thread or client. This would be very bad obviously. Is this design safe in this regard? Is there something I can add that would add the necessary locking to make it safe? Note: I am aware of IDENTITY inserts in SQL Server - and that is not what I am looking for this in particular case. Specifically, I don't want to be inserting/deleting rows. This is basically to have a central table that manages the sequential number generator for a bunch of sequences.

    Read the article

  • Getting records from a table based on a filter field and Between but also having the OR login for mu

    - by Pentium10
    I have a this table, where I store multiple ids and an age range (def1,def2) CREATE TABLE "template_requirements" ("_id" INTEGER NOT NULL, "templateid" INTEGER, "def1" VARCHAR(255), "def2" VARCHAR(255), PRIMARY KEY("_id")) Having values such as: templateid | def1 | def2 100 | 7 | 25 200 | 40 | 90 300 | 7 | 25 300 | 40 | 60 as you see for templateid 300 we have an or logic: age between 7 and 25 or age between 40 and 60. I want to get all the template ids that are not for a certain age like 25... What's the problem? If I run a query like this one: SELECT group_concat(templateid) FROM template_requirements where and '25' not between cast(def1 as integer) and cast(def2 as integer) it returns 200, 300, which is wrong, as the 300 matched on row 40 to 60, but shouldn't be included in the result as we have a condition with same templateid 7 to 25 that fails the not beetween stuff. How would be the correct query in SQLite, I would like to keep the group_concat stuff.

    Read the article

  • How to store matrix information in MySQL?

    - by dedalo
    Hi, I'm working on an application that analizes music similarity. In order to do that I proccess audio data and store the results in txt files. For each audio file I create 2 files, 1 containing and 16 values (each value can be like this:2.7000023942731723) and the other file contains 16 rows, each row containing 16 values like the one previously shown. I'd like to store the contents of these 2 file in a table of my MySQL database. My table looks like: Name varchar(100) Author varchar (100) in order to add the content of those 2 file I think I need to use the BLOB data type: file1 blob file2 blob My question is how should I store this info in the data base? I'm working with Java where I have a double array containing the 16 values (for the file1) and a matrix containing the file2 info. Should I process the values as strings and add them to the columns in my database? Thanks

    Read the article

  • How can I do a left outer join where both tables have a where clause?

    - by cdeszaq
    Here's the scenario: I have 2 tables: CREATE TABLE dbo.API_User ( id int NOT NULL, name nvarchar(255) NOT NULL, authorization_key varchar(255) NOT NULL, is_active bit NOT NULL ) ON [PRIMARY] CREATE TABLE dbo.Single_Sign_On_User ( id int NOT NULL IDENTITY (1, 1), API_User_id int NOT NULL, external_id varchar(255) NOT NULL, user_id int NULL ) ON [PRIMARY] What I am trying to return is the following: is_active for a given authorization_key The Single_Sign_On_User.id that matches the external_id/API_User_id pair if it exists or NULL if there is no such pair When I try this query: SELECT Single_Sign_On_User.id, API_User.is_active FROM API_User LEFT OUTER JOIN Single_Sign_On_User ON Single_Sign_On_User.API_User_id = API_User.id WHERE Single_Sign_On_User.external_id = 'test_ext_id' AND API_User.authorization_key = 'test' where the "test" API_User record exists but the "test_ext_id" record does not, and with no other values in either table, I get no records returned. When I use: SELECT Single_Sign_On_User.id, API_User.is_active FROM API_User LEFT OUTER JOIN Single_Sign_On_User ON Single_Sign_On_User.API_User_id = API_User.id WHERE API_User.authorization_key = 'test' I get the results I expect (NULL, 1), but that query doesn't allow me to find the "test_ext_id" record if it exists but would give me all records associated with the "test" API_User record. How can I get the results I am after?

    Read the article

  • Problem with joining to an empty table

    - by Imran Omar Bukhsh
    I use the following query: select * from A LEFT JOIN B on ( A.t_id != B.t_id) to get all the records in A that are not in B. The results are fine except when table B is completely empty, but then I do not get any records, even from table A. Later It wont work yet! CREATE TABLE IF NOT EXISTS T1 ( id int(11) unsigned NOT NULL AUTO_INCREMENT, title varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, t_id int(11) NOT NULL, PRIMARY KEY (id) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; -- -- Dumping data for table T1 INSERT INTO T1 (id, title, t_id) VALUES (1, 'apple', 1), (2, 'orange', 2); -- -- Table structure for table T2 CREATE TABLE IF NOT EXISTS T2 ( id int(11) NOT NULL AUTO_INCREMENT, title varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, t_id int(11) NOT NULL, PRIMARY KEY (id) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; -- -- Dumping data for table T2 INSERT INTO T2 (id, title, t_id) VALUES (1, 'dad', 2); Now I want to get all records in T1 that do not have a corresponding records in T2 I try SELECT * FROM T1 LEFT OUTER JOIN T2 ON T1.t_id != T2.t_id and it won't work

    Read the article

  • i need to do a view in sql that returns the latest invoice date for each company

    - by dave haughton
    hi, i have a company table that is dbo.companies and has companyId as a column. I also have an invoice table that is dbo.invoices with invoicecompanyId column (which is the same as the companyId on the other table) and it also has a column called invoicedate. What i am mtrying to achieve is a view of each companyid with the corresponding latest invoice date for all the companies i have. i have done the following but i dont know how to filter for the latest invoice, it returns all invoices from all companies and i need latest invoice for all companies SELECT TOP (100) PERCENT 'A' + SUBSTRING('000000', 1, 6 - LEN(CAST(dbo.companies.companyId AS varchar(10)))) + CAST(dbo.companies.companyId AS varchar(10)) AS Client_ID, dbo.invoices.invoiceDate AS S_Inv_Date FROM dbo.invoices INNER JOIN dbo.companies ON dbo.invoices.invoiceCompanyId = dbo.companies.companyId ORDER BY Client_ID can you help please ta

    Read the article

  • What is the most "database independent" way of creating a variable length text field in a database

    - by Thibaut Colar
    I want to create a text field in the database, with no specific size (it will store text of length unknown in some case) - the particular text are serialized simple object (~ JSON) What is the most database independent way to do this : - a varchar with no size specified (don't think all db support this) - a 'text' field, this seems to be common, but I don't believe it's a standard - a blob or other object of that kind ? - a varchar of a a very large size (that's inefficient and wastes disk space probably) - Other ? I'm using JDBC, but I'd like to use something that is supported in most DB (oracle, mysql, postgresql, derby, HSQL, H2 etc...) Thanks.

    Read the article

  • Getting a query to index seek (rather than scan)

    - by PaulB
    Running the following query (SQL Server 2000) the execution plan shows that it used an index seek and Profiler shows it's doing 71 reads with a duration of 0. select top 1 id from table where name = '0010000546163' order by id desc Contrast that with the following with uses an index scan with 8500 reads and a duration of about a second. declare @p varchar(20) select @p = '0010000546163' select top 1 id from table where name = @p order by id desc Why is the execution plan different? Is there a way to change the second method to seek? thanks EDIT Table looks like CREATE TABLE [table] ( [Id] [int] IDENTITY (1, 1) NOT NULL , [Name] [varchar] (13) COLLATE Latin1_General_CI_AS NOT NULL) Id is primary clustered key There is a non-unique index on Name and a unique composite index on id/name There are other columns - left them out for brevity

    Read the article

  • SQLite: Simple DELETE statement did not work

    - by user186446
    I have a table MRU, that has 3 columns. (VALUE varchar(255); TYPE varchar(20); DT_ADD datetime) This is a table simply storing an entry and recording the date time it was recorded. What I wanted to do is: delete the oldest entry whenever I add a new entry that exceeds a certain number. here is my query: delete from MRU where type = 'FILENAME' ORDER BY DT_ADD limit 1; The query returns an error. Thanks

    Read the article

  • string update in sqlserver

    - by Thiyaneshwaran S
    Currently i have varchar field. The delimiter is "$P$P$". The delimiter will appear atleast once and atmost twice in the varchar data. Eg. Sample Heading$P$P$Sample description$P$P$Sample conclusion Sample Heading$P$P$Sample Description If the delimiter appears twice, i need to insert a text before the second occurance of the delimiter. Eg: Sample Heading$P$P$Sample DescriptionINSERT TEXT HERE$P$P$Sample Conclusion If the delimiter occurs only once, then i need to insert a text at the end of the field. Eg: Sample Heading$P$P$Sample DescriptionAPPEND TEXT HERE How this can be done in sql query?

    Read the article

  • How many Stored Procedures created everyday ( problem in converting Datetime )?

    - by Space Cracker
    I make a query that return to me the count of Stored Procedure that created everyday as follow SELECT convert(varchar, crdate, 103) as Date,Count(*) as Counter FROM sysobjects WHERE (xtype = 'p') AND (name NOT LIKE 'dt%') Group by convert(varchar, crdate, 103) and its already work but dates appear in string format that i can't order it such as below 01/03/2010 3 01/04/2008 4 01/05/2010 5 01/11/2008 1 01/12/2008 4 02/03/2008 1 02/03/2010 2 02/04/2008 4 02/05/2010 2 02/11/2008 2 02/11/2009 2 02/12/2008 4 03/01/2010 1 03/02/2010 2 03/03/2010 2 03/04/2008 2 03/04/2010 2 03/05/2008 1 03/05/2010 2 I want to make that in which date is in datetime format that i can make order by successfully, i tried convert(datetime, crdate, 103) but it show Full date any idea of how to do ?

    Read the article

  • mysql count(*) left join group by - the number of files in a folder

    - by Flavius
    Hi I have the following tables CREATE TABLE `files` ( `fileid` int(11) NOT NULL AUTO_INCREMENT, `filename` varchar(255) NOT NULL, `filesize` int(11) NOT NULL, `folder` int(11) NOT NULL, PRIMARY KEY (`fileid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; CREATE TABLE `folders` ( `directoryid` int(11) NOT NULL AUTO_INCREMENT, `directoryname` varchar(255) NOT NULL, PRIMARY KEY (`directoryid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; How to get a list of all folders and the number of files they hold, including folders who have no (zero) files? Recursion must not be taken into account. Found it select folders.directoryid, folders.directoryname, count(files.fileid) as no_files from folders left join files on files.folder = folders.directoryid group by folders.directoryid, folders.directoryname I hope it will help someone.

    Read the article

  • Normalize database or not? Read only MyISAM table, performance is the main priority (MySQL)

    - by hello
    I'm importing data to a future database that will have one, static MyISAM table (will only be read from). I chose MyISAM because as far as I understand it's faster for my requirements (I'm not very experienced with MySQL / SQL at all). That table will have various columns such as ID, Name, Gender, Phone, Status... and Country, City, Street columns. Now the question is, should I create tables (e.g Country: Country_ID, Country_Name) for the last 3 columns and refer to them in the main table by ID (normalize...[?]), or just store them as VARCHAR in the main table (having duplicates, obviously)? My primary concern is speed - since the table won't be written into, data integrity is not a priority. The only actions will be selecting a specific row or searching for rows that much a certain criteria. Would searching by the Country, City and/or Street columns (and possibly other columns in the same search) be faster if I simply use VARCHAR?

    Read the article

  • Implicit type conversion in DB/2 inserts?

    - by IronGoofy
    We're using SQL Inserts to insert some data via a script into DB/2 tables, e.g. CREATE TABLE TICKETS (TICKETID VARCHAR(10) NOT NULL); On my home installation, this statement works fine (note that I'm using an integer which is autoatically cast into a VarChar): INSERT INTO TICKETS (TICKETID) VALUES (1); while at my customer's site I get a type error. My question(s): Is this behavior version dependent? (I use a DB2 Express V9.7, while the customer has an Enterprise V9.5) Is there a config option to change the behavior? (I would like my home install to behave as close as possible as the production environment is going to be.)

    Read the article

  • MySQL comparisons between multiple rows

    - by Hurpe
    I have a MySQL table with the following columns: id(int), date (timestamp), starttime(varchar), endtime(varchar), ... I need to find time slots that are occupied by two or more rows. Here is an example table id| date |starttime|endtime | __|_____________________|_________|________| 1 | 2010-02-16 17:37:36 |14:35:00 |17:37:00| 2 | 2010-02-17 12:24:22 |12:13:00 |14:32:00| 3 | 2010-02-16 12:24:22 |15:00:00 |18:00:00| Rows 1 and 3 collide, and need to be corrected by the user. I need a query to identify such colliding rows - something that would give me the ID of all rows in the collision. When inserting data in the database I find collisions with this query: SELECT ID FROM LEDGER WHERE DATE(DATE) = DATE('$timestamp') AND ( STR_TO_DATE('$starttime','%H:%i:%s') BETWEEN STR_TO_DATE(STARTTIME,'%H:%i:%s') AND STR_TO_DATE(ENDTIME,'%H:%i:%s') OR STR_TO_DATE('$endtime','%H:%i:%s') BETWEEN STR_TO_DATE(STARTTIME,'%H:%i:%s') AND STR_TO_DATE(ENDTIME,'%H:%i:%s') ) AND FNAME = '$fname'"; Is there any way to accomplish this strictly using MySQL or do I have to use PHP to find the collisions?

    Read the article

  • Can MySQL automatically specify `_utf8` for inserts to UTF-8 columns?

    - by Neil
    I have a table like this, where one column is latin1, the other is UTF-8: Create Table: CREATE TABLE `names` ( `name_english` varchar(255) character NOT NULL, `name_chinese` varchar(255) character set utf8 default NULL, ) ENGINE=MyISAM DEFAULT CHARSET=latin1 When I do an insert, I have to type _utf8 before values being inserted into UTF-8 columns: insert into names (name_english = "hooey", name_chinese = _utf8 "??"); However, since MySQL should know that name_chinese is a UTF-8 column, it should be able to know to use _utf8 automatically. Is there any way to tell MySQL to use _utf8 automatically, so when I'm programatically making prepared statements, I don't have to worry about including it with the right parameters?

    Read the article

  • SQL most popular

    - by Brae
    I have a mysql table with items in relation to their order. CREATE DATABASE IF NOT EXISTS `sqltest`; USE `sqltest`; DROP TABLE IF EXISTS `testdata`; CREATE TABLE `testdata` ( `orderID` varchar(10) DEFAULT NULL, `itemID` varchar(10) DEFAULT NULL, `qtyOrdered` int(10) DEFAULT NULL, `sellingPrice` decimal(10,2) DEFAULT NULL ) INSERT INTO `testdata`(`orderID`,`itemID`,`qtyOrdered`,`sellingPrice`) values ('1','a',1,'7.00'),('1','b',2,'8.00'),('1','c',3,'3.00'),('2','a',1,'7.00'),('2','c',4,'3.00'); Intended Result: A = (1+1)2 B = 2 C = (2+4)6 <- most popular How do I add up all the qty's for each item and result the highest one? It should be fairly strait forward but I'm new to SQL and I can't work this one out :S Solution needs to be mysql and or php. I guess there needs to be some sort of temporary tally variable for each item ID, but that seems like it could get messy with too many items.

    Read the article

  • Check If Stored Procedure Returns Value

    - by Eric
    Hello all, I am using Linq 2 Sql in VS 2010, and I have the following stored procedure to check a username and password ALTER PROCEDURE dbo.CheckUser ( @username varchar(50), @password varchar(50) ) AS SELECT * FROM Users Where UserName=@username AND Password=@password The problem I'm having is that it throws an exception if the username and password are incorrect. I'd like to perform a check to see if there is a return value, rather than using try/catch to determine whether the procedure returned a value. Should I do this check in code (C#)? Or is there a way to do it in SQL? Thanks.

    Read the article

  • Which MySQL Datatype to use for storing boolean values from/to PHP?

    - by Beat
    Since MySQL doesn't seem to have any 'boolean' datatype, which datatype do you 'abuse' for storing true/false information in MySQL? Especially in the context of writing and reading from/to a PHP-Script. Over time I have used and seen several approaches: tinyint, varchar fields containing the values 0/1, varchar fields containing the strings '0'/'1' or 'true'/'false' and finally enum Fields containing the two options 'true'/'false'. None of the above seems optimal, I tend to prefer the tinyint 0/1 variant, since automatic type conversion in PHP gives me boolean values rather simply. So which datatype do you use, is there a type designed for boolean values which I have overlooked? Do you see any advantages/disadvantages by using one type or another?

    Read the article

  • error defining foreign key PhpMyAdmin

    - by Ngounou lassale
    I am new to PhpMyAdmin. I will like to create a foreign key for my tables. In fact i have create tableI with this structures(A as int(11) autoincrement, B as varchar) TableII ( A_2 as int(11) auto increment, B_2 as varchar, A as int(11). I have declared A as an index in tableII, now when i go to relationship view to precise A as a foreign key i always have this error Erreur lors de la création de la clé étrangère sur ID_Ville (vérifiez le type des colonnes) Erreur ALTER TABLE tb_quartier ADD FOREIGN KEY ( ID_Ville ) REFERENCES ingenieris2.tb_ville ( ID_Ville ) ON DELETE RESTRICT ; Please Help thanks!

    Read the article

  • Numeric literals in sql server 2008

    - by costa
    What is the type that sql server assigns to the numeric literal: 2. , i.e. 2 followed by a dot? I was curious because: select convert(varchar(50), 2.) union all select convert(varchar(50), 2.0) returns: 2 2.0 which made me ask what's the difference between 2. and 2.0 type wise? Sql server seems to assign types to numeric literals depending on the number itself by finding the minimal storage type that can hold the number. A value of 1222333 is stored as int while 1152921504606846975 is stored as big int. thanks

    Read the article

< Previous Page | 30 31 32 33 34 35 36 37 38 39 40 41  | Next Page >