Search Results

Search found 10060 results on 403 pages for 'column'.

Page 9/403 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • How to insert and call by row and column into sqlite3 python

    - by user291071
    Lets say i have a simple array of x rows and y columns with corresponding values, What is the best method to do 3 things? How to insert, update a value at a specific row column? How to select a value for each row and column, import sqlite3 con = sqlite3.connect('simple.db') c = con.cursor() c.execute('''create table simple (links text)''') con.commit() dic = {'x1':{'y1':1.0,'y2':0.0},'x2':{'y1':0.0,'y2':2.0,'y3':1.5},'x3':{'y2':2.0,'y3':1.5}} ucols = {} ## my current thoughts are collect all row values and all column values from dic and populate table row and columns accordingly how to call by row and column i havn't figured out yet ##populate rows in first column for row in dic: print row c.execute("""insert into simple ('links') values ('%s')"""%row) con.commit() ##unique columns for row in dic: print row for col in dic[row]: print col ucols[col]=dic[row][col] ##populate columns for col in ucols: print col c.execute("alter table simple add column '%s' 'float'" % col) con.commit() #functions needed ##insert values into sql by row x and column y?how to do this e.g. x1 and y2 should put in 0.0 ##I tried as follows didn't work for row in dic: for col in dic[row]: val =dic[row][col] c.execute("""update simple SET '%s' = '%f' WHERE 'links'='%s'"""%(col,val,row)) con.commit() ##update value at a specific row x and column y? ## select a value at a specific row x and column y?

    Read the article

  • SQL SERVER – Solution of Puzzle – Swap Value of Column Without Case Statement

    - by pinaldave
    Earlier this week I asked a question where I asked how to Swap Values of the column without using CASE Statement. Read here: SQL SERVER – A Puzzle – Swap Value of Column Without Case Statement. I have proposed 3 different solutions in the blog posts itself. I had requested the help of the community to come up with alternate solutions and honestly I am stunned and amazed by the qualified entries. I will be not able to cover every single solution which is posted as a comment, however, I would like to for sure cover few interesting entries. However, I am selecting 5 solutions which are different (not necessary they are most optimal or best – just different and interesting). Just for clarity I am involving the original problem statement here. USE tempdb GO CREATE TABLE SimpleTable (ID INT, Gender VARCHAR(10)) GO INSERT INTO SimpleTable (ID, Gender) SELECT 1, 'female' UNION ALL SELECT 2, 'male' UNION ALL SELECT 3, 'male' GO SELECT * FROM SimpleTable GO -- Insert Your Solutions here -- Swap value of Column Gender SELECT * FROM SimpleTable GO DROP TABLE SimpleTable GO Here are the five most interesting and different solutions I have received. Solution by Roji P Thomas UPDATE S SET S.Gender = D.Gender FROM SimpleTable S INNER JOIN SimpleTable D ON S.Gender != D.Gender I really loved the solutions as it is very simple and drives the point home – elegant and will work pretty much for any values (not necessarily restricted by the option in original question ‘male’ or ‘female’). Solution by Aneel CREATE TABLE #temp(id INT, datacolumn CHAR(4)) INSERT INTO #temp VALUES(1,'gent'),(2,'lady'),(3,'lady') DECLARE @value1 CHAR(4), @value2 CHAR(4) SET @value1 = 'lady' SET @value2 = 'gent' UPDATE #temp SET datacolumn = REPLACE(@value1 + @value2,datacolumn,'') Aneel has very interesting solution where he combined both the values and replace the original value. I personally liked this creativity of the solution. Solution by SIJIN KUMAR V P UPDATE SimpleTable SET Gender = RIGHT(('fe'+Gender), DIFFERENCE((Gender),SOUNDEX(Gender))*2) Sijin has amazed me with Difference and Soundex function. I have never visualized that above two functions can resolve the problem. Hats off to you Sijin. Solution by Nikhildas UPDATE St SET St.Gender = t.Gender FROM SimpleTable St CROSS Apply (SELECT DISTINCT gender FROM SimpleTable WHERE St.Gender != Gender) t I was expecting that someone will come up with this solution where they use CROSS APPLY. This is indeed very neat and for sure interesting exercise. If you do not know how CROSS APPLY works this is the time to learn. Solution by mistermagooo UPDATE SimpleTable SET Gender=X.NewGender FROM (VALUES('male','female'),('female','male')) AS X(OldGender,NewGender) WHERE SimpleTable.Gender=X.OldGender As per author this is a slow solution but I love how syntaxes are placed and used here. I love how he used syntax here. I will say this is the most beautifully written solution (not necessarily it is best). Bonus: Solution by Madhivanan Somehow I was confident Madhi – SQL Server MVP will come up with something which I will be compelled to read. He has written a complete blog post on this subject and I encourage all of you to go ahead and read it. Now personally I wanted to list every single comment here. There are some so good that I am just amazed with the creativity. I will write a part of this blog post in future. However, here is the challenge for you. Challenge: Go over 50+ various solutions listed to the simple problem here. Here are my two asks for you. 1) Pick your best solution and list here in the comment. This exercise will for sure teach us one or two things. 2) Write your own solution which is yet not covered already listed 50 solutions. I am confident that there is no end to creativity. Reference: Pinal Dave (http://blog.SQLAuthority.com) Filed under: PostADay, SQL, SQL Authority, SQL Function, SQL Puzzle, SQL Query, SQL Server, SQL Tips and Tricks, T SQL, Technology

    Read the article

  • ALTER TABLE on dependant column

    - by Sharmi
    I am trying to alter column datatype of a primary key to tinyint from int.This column is a foreign key in other tables.So,I get the following error: Msg 5074, Level 16, State 1, Line 1 The object 'PK_User_tbl' is dependent on column 'appId'. Msg 5074, Level 16, State 1, Line 1 The object 'FK_Details_tbl_User_tbl' is dependent on column 'appId'. Msg 5074, Level 16, State 1, Line 1 The object 'FK_Log_tbl_User_tbl' is dependent on column 'appId'. Msg 4922, Level 16, State 9, Line 1 ALTER TABLE ALTER COLUMN appId failed because one or more objects access this column. Howw should i rectify this?

    Read the article

  • Stretch column table in Primefaces

    - by Orange91
    How I can prevent to stretch table when I input long text: Screen: http://zapodaj.net/71821572f2445.jpg.html Meyby is it possible to make the text lines stretched row horizontally? My fragment example table: <p:dataTable id="table" styleClass="table" value="#{userMB.allInactive}" var="inactive" paginator="true" rows="15" rowKey="#{inactive.id}" selection="#{userMB.user}" selectionMode="single" > <f:facet name="header"> Lista kont nieaktywnych </f:facet> <p:column headerText="#{msg.firstName}"> <h:outputText value="#{inactive.firstName}" /> </p:column> I tried <p:column headerText="#{msg.firstName}" width="20px"> styleClass for column: <p:column styleClass="column" headerText="#{msg.firstName}" width="20px"> .column { width: 20px; } but I do not see any change, it does not work.

    Read the article

  • MYSQL Query with 2 columns in Table A related to 1 column in Table B

    - by CYREX
    I have 2 Tables, User and Mail. In User Table i have 2 columns that i will use, the ID column which makes the relation with the Mail Table and it is the Index of User Table and the Name column. In Mail Table i have Receiver Column and Sender Column. Both columns, Receiver and Sender have a number that relates to the ID Column in the User Table. In the User Table is where the name columns resides and i want to make a query that shows me the Receiver and Sender Columns but with the name of the user, not the ID. Up to this point i have this: SELECT name AS Send, name AS Receive FROM mail,user WHERE sender=guid; I know there is still a part of the query missing but i can not figure out what else to put to tell it to show in the SEND output column the name of the sender and in the RECEIVE output column the name of the receiver.

    Read the article

  • full-text property change on column

    - by matt99
    Hello, i'm trying to modify a property of a column (in sql server 2008 r2) which is of xml data type. I want set (Is full-text indexed) to yes, but after I do this and try to save changes, i get an error: 'Abc' table - Unable to modify table. Column: B is not full-text searchable. Column B is not the column I'm modyfing, but it's content is based on the modified xml column (it takes a value from one element in xml). Weird thing is that column B is full-text indexed (in table designer). Any ideas why i cannot apply changes to the xml column?

    Read the article

  • MySQL : Calculate business day difference between two dates column

    - by yokoyoko
    My sql query returns back two columns, first column is "date created" and second column is "date updated", first column has a prior timestamp with respect to second column. I need to add a third column which can display business day hrs (9:00am to 5:00pm) response i.e. if date created is 2012-01-01 09:00:20 and "dated updated" is 4:00pm same day then third column should display 7 hrs If date created is 2012-01-01 16:00:20 (4:00pm) and "date updated" is 10:00m on 2012:01:02 (2nd Jan) then third column should display 2 hrs. It should exclude Saturday and Sunday. Can you please suggest appropriate SQL query for this.

    Read the article

  • how to get width of column in charting ColumnSeries. I have not DataPointStyle. It takes the default

    - by KK
    how to get width of column in charting ColumnSeries. I have not DataPointStyle. It takes the default I have set the itemssource to col.ItemsSource = new KeyValuePair[]{ new KeyValuePair(DateTime.Now.AddMonths(1), 100), new KeyValuePair(DateTime.Now.AddMonths(2), 200), new KeyValuePair(DateTime.Now.AddMonths(3), 300), new KeyValuePair(DateTime.Now.AddMonths(4), 400) }; I get 4 column with some even width. How to I print its value .... its taking it by default ... thank you.

    Read the article

  • In R, when using named rows, can a sparse matrix column be added to another sparse matrix?

    - by ayman
    I have two sparse matrices, m1 and m2: > m1 <- Matrix(data=0,nrow=2, ncol=1, sparse=TRUE, dimnames=list(c("b","d"),NULL)) > m2 <- Matrix(data=0,nrow=2, ncol=1, sparse=TRUE, dimnames=list(c("a","b"),NULL)) > m1["b",1]<- 4 > m2["a",1]<- 5 > m1 2 x 1 sparse Matrix of class "dgCMatrix" b 4 d . > m2 2 x 1 sparse Matrix of class "dgCMatrix" a 5 b . > and I want to cbind() them to make a sparse matrix like: [,1] [,2] a . 5 b 4 . d . . however cbind() ignores the named rows: > cbind(m1[,1],m2[,1]) [,1] [,2] b 4 5 d 0 0 is there some way to do this without a brute force loop?

    Read the article

  • Execution time of ALTER COLUMN

    - by Tommy Jakobsen
    Having a table with 60 columns, and 200 rows. Altering a BIT column from NULL to NOT NULL, now has a running execution time of over 3 hours. Why is this taking so long? This is the query that I'm execution: ALTER TABLE tbl ALTER COLUMN col BIT NOT NULL Is there a faster way to do it, besides creating a new column, updating it with values from the old column, then dropping the old column and renaming the new one? This is on MS SQL Server 2005.

    Read the article

  • SQLAlchemy custom query column

    - by thrillerator
    I have a declarative table defined like this: class Transaction(Base): __tablename__ = "transactions" id = Column(Integer, primary_key=True) account_id = Column(Integer) transfer_account_id = Column(Integer) amount = Column(Numeric(12, 2)) ... The query should be: SELECT id, (CASE WHEN transfer_account_id=1 THEN -amount ELSE amount) AS amount FROM transactions WHERE account_id = 1 OR transfer_account_id = 1 My code is: query = Transaction.query.filter_by(account_id=1, transfer_account_id=1) query = query.add_column(func.case(...).label("amount") But it doesn't replace the amount column. Been trying to do this with for hours and I don't want to use raw SQL.

    Read the article

  • How sort a QuantumGrid on data from a different column

    - by norgepaul
    Is there a way to sort Devexpress QuantumGrid rows on data from a different column other than the one whose header has been clicked? For example, when the header of column A is clicked the rows of the grid are sorted on the data from column B. Visually it should still appear that it is column A that has been sorted as the sort glyphys will be shown in column A's header.

    Read the article

  • How to create a dynamic width column in Twitter Bootstrap

    - by Elad
    How do you use Twitter Bootstrap to create a table-like list structure, where some columns take as much space as required to accommodate the widest element of that column, and a single column takes the remaining space? For example Id |Name |Email address 100001|Joe |[email protected] 100 |Christine|[email protected] 1001 |John |[email protected] the Id column takes just enough space to accommodate the 100001 id which is the longest id, and the Name column takes just enough space to accommodate the name Christine. The Email column takes the remaining space.

    Read the article

  • How to sort a QuantumGrid on data from a different column

    - by norgepaul
    Is there a way to sort Devexpress QuantumGrid rows on data from a different column other than the one whose header has been clicked? For example, when the header of column A is clicked the rows of the grid are sorted on the data from column B. Visually it should still appear that it is column A that has been sorted as the sort glyphys will be shown in column A's header.

    Read the article

  • Get column name in jpa

    - by German
    Hi all, I have a query factory that takes a column name as an attribute in order to search for that column. Right now I'm passing the name of the column as a string, so it's kind of hardcoded. If the name of the column changes in the entity's annotation, that "hidden dependency" breaks up. Is there a way in jpa to retrieve the real name of the column and have it available at compile time, so I can use it in queries?

    Read the article

  • Does SQL Server guarantee sequential inserting of an identity column?

    - by balpha
    In other words, is the following "cursoring" approach guaranteed to work: retrieve rows from DB save the largest ID from the returned records for later, e.g. in LastMax later, "SELECT * FROM MyTable WHERE Id > {0}", LastMax In order for that to work, I have to be sure that every row I didn't get in step 1 has an Id greater than LastMax. Is this guaranteed, or can I run into weird race conditions?

    Read the article

  • How to generate a script for changing a column of varchar to xml type with data being converted?

    - by user1323981
    Initially I have a column (partner_email) of varchar.Now a recent change has come where it needs to be changed to be changed to the XML type but the previous records needs to be reserve into the new column. I have applied the below algorithm to accomplish the work /*********************************************************************** Purpose: To change the partner_email column from Varchar Type To Xml Type and convert the existing records from varchar to xml types. Programmers Notes: 1. Create a new Column by the name partner_email_temp of type XML into the Partner Table 2. Copy the Email contents from partner_email to partner_email_temp column after proper conversion N.B.~ The format will be <PartnerEmails> <Email>[email protected]</Email> <Email /> <Email /> </PartnerEmails> 3. Drop the exisitng partner_email 4. Rename partner_email_temp column to partner_email ***********************************************************************/ USE [Test] GO --===== Create a partner_email_temp column of type xml into the Partner table IF NOT EXISTS ( SELECT * FROM INFORMATION_SCHEMA.columns WHERE table_name = 'Partner' AND column_name = 'partner_email_temp' ) BEGIN ALTER TABLE [dbo].[Partner] ADD partner_email_temp XML NULL END GO --===== Copy the Email contents from partner_email to partner_email_temp column -- after proper conversion to xml type UPDATE [dbo].[Partner] SET partner_email_temp = CAST('<PartnerEmails><Email>' + REPLACE(partner_email, '&', '&amp;') + '</Email><Email></Email><Email></Email></PartnerEmails>' AS XML) GO --===== Drop the exisitng partner_email ALTER TABLE [dbo].[Partner] DROP COLUMN partner_email GO --===== Rename partner_email_temp column to partner_email Exec sp_RENAME 'Partner.partner_email_temp','partner_email','COLUMN' GO I works fine for the first time I ran. Now if I ran it for the next time, it am getting an error Msg 8116, Level 16, State 1, Line 4 Argument data type xml is invalid for argument 1 of replace function. Caution: Changing any part of an object name could break scripts and stored procedures. The intention is that, if the partner_email column is varchar, the script will change it to xml type and will convert all the data in xml format . If I ran it second time, it should ignore the statement. How to achieve this? I am trying in a different way DECLARE @columnDataType VARCHAR(50) SELECT @columnDataType = DATA_TYPE FROM INFORMATION_SCHEMA.columns WHERE table_name = 'Partner' AND column_name = 'partner_email' print @columnDataType IF (@columnDataType = 'varchar') BEGIN --===== Create a partner_email_temp column of type xml into the Partner table IF NOT EXISTS ( SELECT * FROM INFORMATION_SCHEMA.columns WHERE table_name = 'Partner' AND column_name = 'partner_email_temp' ) BEGIN ALTER TABLE [dbo].[Partner] ADD partner_email_temp XML NULL --===== Copy the Email contents from partner_email to partner_email_temp column -- after proper conversion to xml type UPDATE [dbo].[Partner] SET partner_email_temp = CAST('<PartnerEmails><Email>' + REPLACE(partner_email, '&', '&amp;') + '</Email><Email></Email><Email></Email></PartnerEmails>' AS XML) --===== Drop the exisitng partner_email ALTER TABLE [dbo].[Partner] DROP COLUMN partner_email --===== Rename partner_email_temp column to partner_email EXEC sp_RENAME 'Partner.partner_email_temp','partner_email','COLUMN' END END but getting error Msg 207, Level 16, State 1, Line 29 Invalid column name 'partner_email_temp'. Help needed

    Read the article

  • How to structure classes in the filesystem?

    - by da_b0uncer
    I have a few (view) classes. Table, Tree, PagingColumn, SelectionColumn, SparkLineColumn, TimeColumn. currently they're flat under app/view like this: app/view/Table app/view/Tree app/view/PagingColumn ... I thought about restructuring it, because the Trees and Tables use the columns, but there are some columns, which only work in a tree, some who work in trees and tables and in the future there are probably some who only work in tables, I don't know. My first idea was like this: app/view/Table app/view/Tree app/view/column/PagingColumn app/view/column/SelectionColumn app/view/column/SparkLineColumn app/view/column/TimeColumn But since the SelectionColumn is explicitly for trees, I have the fear that future developers could get the idea of missuse them. But how to restructure it probably? Like this: app/view/table/panel/Table app/view/tree/panel/Tree app/view/tree/column/PagingColumn app/view/tree/column/SelectionColumn app/view/column/SparkLineColumn app/view/column/TimeColumn Or like this: app/view/Table app/view/Tree app/view/column/SparkLineColumn app/view/column/TimeColumn app/view/column/tree/PagingColumn app/view/column/tree/SelectionColumn

    Read the article

  • Using SqlServer 2008 and TSQL Subtract 1 Hour From All Values In a DateTime Column

    In this post, well go briefly the process of how you would update all rows in a SQL Server 2008 table such that a particular date column will be moved back 1 hour in time.  This is actually pretty simple, but being that I typically do my work in the ORM layer (that is LINQ2SQL [...]...Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • SQL SERVER – DVM sys.dm_os_sys_info Column Name Changed in SQL Server 2012

    - by pinaldave
    Have you ever faced situation where something does not work and when you try to go and fix it – you like fixing it and started to appreciate the breaking changes. Well, this is exactly I felt yesterday. Before I begin my story of yesterday I want to state it candidly that I do not encourage anybody to use * in the SELECT statement. One of the my DBA friend who always used my performance tuning script yesterday sent me email asking following question - “Every time I want to retrieve OS related information in SQL Server – I used DMV sys.dm_os_sys_info. I just upgraded my SQL Server edition from 2008 R2 to SQL Server 2012 RC0 and it suddenly stopped working. Well, this is not the production server so the issue is not big yet but eventually I need to resolve this error. Any suggestion?” The funny thing was original email was very long but it did not talk about what is the exact error beside the query is not working. I think this is the disadvantage of being too friendly on email sometime. Well, never the less, I quickly looked at the DMV on my SQL Server 2008 R2 and SQL Server 2012 RC0 version. To my surprise I found out that there were few columns which are renamed in SQL Server 2012 RC0. Usually when people see breaking changes they do not like it but when I see these changes I was happy as new names were meaningful and additionally their new conversion is much more practical and useful. Here are the columns previous names - Previous Column Name New Column Name physical_memory_in_bytes physical_memory_kb bpool_commit_target committed_target_kb bpool_visible visible_target_kb virtual_memory_in_bytes virtual_memory_kb bpool_commited committed_kb If you read it carefully you will notice that new columns now display few results in the KB whereas earlier result was in bytes. When I see the results in bytes I always get confused as I could not guess what exactly it will convert to. I like to see results in kb and I am glad that new columns are now displaying the results in the kb. I sent the details of the new columns to my friend and ask him to check the columns used in application. From my comment he quickly realized why he was facing error and fixed it immediately. Overall – all was well at the end and I learned something new. Reference: Pinal Dave (http://blog.SQLAuthority.com) Filed under: Pinal Dave, PostADay, SQL, SQL Authority, SQL DMV, SQL Query, SQL Scripts, SQL Server, SQL Tips and Tricks, T SQL, Technology

    Read the article

  • SQL Server Integration Services 2008: Importing Excel Data Using Derived Column Transformation

    The complexity involved in transferring data between Excel and SQL Server results from different and sometimes incompatible data types. The Import and Export wizard mitigates potential issues introduced by these incompatibilities by taking advantage of Data Conversion Transformation. Marcin Policht describes another approach that produces an equivalent outcome by employing Derived Column Transformation instead.

    Read the article

  • SQL Server v.Next ("Denali") : How a columnstore index is not like a normal index

    - by AaronBertrand
    At the end of my Denali presentation at SQL Saturday #65 in Vancouver, a member of the audience asked, "What makes a columnstore index different from a regular nonclustered index?" At the end of a busy day, I was at a loss for an answer, and I'll explain why. First, I'll briefly explain the basic, core, high-level functionality of a columnstore index (you can read a lot more details in this white paper ). Basically, instead of storing index data together on a page, it divvies up the data from each...(read more)

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >