Search Results

Search found 12215 results on 489 pages for 'identity column'.

Page 58/489 | < Previous Page | 54 55 56 57 58 59 60 61 62 63 64 65  | Next Page >

  • Dynamic SQL to generate column names?

    - by Ben McCormack
    I have a query where I'm trying pivot row values into column names and currently I'm using SUM(Case...) As 'ColumnName' statements, like so: SELECT SKU1, SUM(Case When Sku2=157 Then Quantity Else 0 End) As '157', SUM(Case When Sku2=158 Then Quantity Else 0 End) As '158', SUM(Case When Sku2=167 Then Quantity Else 0 End) As '167' FROM OrderDetailDeliveryReview Group By OrderShipToID, DeliveryDate, SKU1 The above query works great and gives me exactly what I need. However, I'm writing out the SUM(Case... statements by hand based on the results of the following query: Select Distinct Sku2 From OrderDetailDeliveryReview Is there a way, using T-SQL inside a stored procedure, that I can dynamically generate the SUM(Case... statements from the Select Distinct Sku2 From OrderDetailDeliveryReview query and then execute the resulting SQL code?

    Read the article

  • SQlite: Column format for unix timestamp; Integer types

    - by SF.
    Original problem: What is the right column format for a unix timestamp? The net is full of confusion: some posts claim SQLite has no unsigned types - either whatsoever, or with exception of the 64bit int type (but there are (counter-)examples that invoke UNSIGNED INTEGER). The data types page mentions it only in a bigint example. It also claims there is a 6-byte integer but doesn't give a name for it. Of course standard INTEGER being 4-byte signed signed stores unix timestamps as negative numbers. I've heard that some systems return 64-bit timestamps too. OTOH I'm not too fond of wasting 4 bytes to store 1 extra bit (top bit of timestamp), and even if I have to pick a bigger data format, I'd rather go for the 6-byte one. I've even seen a post that claims SQLite unix timestamp is of type REAL... Complete problem: Could someone please clarify that mess?

    Read the article

  • insert into sql table column as GUID

    - by loviji
    I have tried with ado.net create table columnName with unique name. as uniquename I use new Guid() Guid sysColumnName = new Guid(); sysColumnName = Guid.NewGuid(); string stAddColumn = "ALTER TABLE " + tableName + " ADD " + sysColumnName.ToString() + " " + convertedColumnType + " NULL"; SqlCommand cmdAddColumn = new SqlCommand(stAddColumn, con); cmdAddColumn.ExecuteNonQuery(); con.Close(); and it fails: System.Data.SqlClient.SqlException: Incorrect syntax near '-'. ? System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) ? System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) now question, how can i fix it, or how can use different way to create unique column?

    Read the article

  • DataGridView Winform Auto Insert Ordinal Column (Trick)

    - by pang
    I want to get some trick for this problem. I have my table like this Product (uuid, Name) and one datagridview to display this information ( dataGridView.DataSouce = Products which is assign on runtime) My problem is that I want to have "No" column on dataGridView which will show like below No | Name 1 | ProdctA 2 | ProductB 3 | ProductC What I do right now is create a "No" field on my product Model, and loop through all the row and assign value to it. I think this is not a good solution. Hope anyone can suggest better solution. Thanks,

    Read the article

  • Cannot format first column in WxPython's ListCtrl

    - by Matt Clarke
    If I set the format of the first column in a ListCtrl to align centre (or align right) nothing happens. It works for the other columns. This only happens on Windows - I have tested it on Linux and it works fine. Does anyone know if there is a work-round or other solution? Here is an example based on code found at http://zetcode.com/wxpython/ import wx import sys packages = [('jessica alba', 'pomona', '1981'), ('sigourney weaver', 'new york', '1949'), ('angelina jolie', 'los angeles', '1975'), ('natalie portman', 'jerusalem', '1981'), ('rachel weiss', 'london', '1971'), ('scarlett johansson', 'new york', '1984' )] class Actresses(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title, size=(380, 230)) hbox = wx.BoxSizer(wx.HORIZONTAL) panel = wx.Panel(self, -1) self.list = wx.ListCtrl(panel, -1, style=wx.LC_REPORT) self.list.InsertColumn(0, 'name', wx.LIST_FORMAT_CENTRE,width=140) self.list.InsertColumn(1, 'place', wx.LIST_FORMAT_CENTRE,width=130) self.list.InsertColumn(2, 'year', wx.LIST_FORMAT_CENTRE, 90) for i in packages: index = self.list.InsertStringItem(sys.maxint, i[0]) self.list.SetStringItem(index, 1, i[1]) self.list.SetStringItem(index, 2, i[2]) hbox.Add(self.list, 1, wx.EXPAND) panel.SetSizer(hbox) self.Centre() self.Show(True) app = wx.App() Actresses(None, -1, 'actresses') app.MainLoop()

    Read the article

  • fluent nhibernate m-to-m with column

    - by csetzkorn
    Hi, I am used to hbm files and started using fluent nhibernate recently. Creating an m-to-m relationship between two entities A and B is quite simple In A I create: public virtual IList Bs { get; set; } and then I use: mapping.HasManyToMany(x = x.Bs); That’s it and I can do: A a = new A(); a.Bs.Add(b); My problem is that I would like to have an additional column in my dedicated m-to-m database table which holds the two foreign keys. What is the simplest way to achieve this in FNH? Would I have to create a dedicated entity for the m-to-m realtionship or is there a simpler solution? Thanks. Best wishes, Christian

    Read the article

  • Python: convert buffer type of SQLITE column into string

    - by Volatil3
    I am new to Python 2.6. I have been trying to fetch date datetime value which is in yyyy-mm-dd hh:m:ss format back in my Python program. On checking the column type in Python I get the error: 'buffer' object has no attribute 'decode'. I want to use the strptime() function to split the date data and use it but I can't find how to convert a buffer to string. The following is a sample of my code (also available here): conn = sqlite3.connect("mrp.db.db", detect_types=sqlite3.PARSE_DECLTYPES) cursor = conn.cursor() qryT = """ SELECT dateDefinitionTest FROM t WHERE IDproject = 4 AND IDstatus = 5 ORDER BY priority, setDate DESC """ rec = (4,4) cursor.execute(qryT,rec) resultsetTasks = cursor.fetchall() cursor.close() # closing the resultset for item in resultsetTasks: taskDetails = {} _f = item[10].decode("utf-8") The exception I get is: 'buffer' object has no attribute 'decode'

    Read the article

  • ListView GridView column

    - by plotnick
    I got a ListView with GridView and GridViewColumns in it. <ListView> <ListView.View> <GridView> <GridViewColumn> <GridViewColumn.CellTemplate> <DataTemplate> <ComboBox /> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> Now I want in my code to disable the Combobox or entire column. And I don't know how to do it. Help me please.

    Read the article

  • Detect if a table contains a column in Android/sqlite

    - by sandis
    So I have an app on the market, and with an update I want to add some columns to the database. No problems so far. But I want to detect if the database in use is missing these columns, and add them if this is the case. I need this to be done dynamically and not just after the update to the new version, because the application is supposed to still be able to import older databases. Normally I would be able to use the PRAGMA query, but Im not sure how to do this with Android. I cant use execSQL since it is a query, and I cant figure out how to use PRAGMA with the query()-function. Ofcourse I could just catch exceptions and then add the column, or always add the columns to each table before I start to work with it, but that is not a neat solution. Cheers,

    Read the article

  • I need to calculate the date / time difference between one date time column

    - by Stringz
    Details. I have the notes table having the following columns. ID - INT(3) Date - DateTime Note - VARCHAR(100) Tile - Varchar(100) UserName - Varchar(100) Now this table will be having NOTES along with the Titles entered by UserName on the specified date / time. I need to calculate the DateTimeDifference between the TWO ROWS in the SAME COLUMN For example the above table has this peice of information in the table. 64, '2010-03-26 18:16:13', 'Action History', 'sending to Level 2.', 'Salman Khwaja' 65, '2010-03-26 18:19:48', 'Assigned By', 'This is note one for the assignment of RF.', 'Salman Khwaja' 66, '2010-03-27 19:19:48', 'Assigned By', 'This is note one for the assignment of CRF.', 'Salman Khwaja' Now I need to have the following resultset in query reports using MYSQL. TASK - TIME Taken ACTION History - 2010-03-26 18:16:13 Assigned By - 00:03:35 Assigned By - 25:00:00 More smarter approach would be TASK - TIME Taken ACTION History - 2010-03-26 18:16:13 Assigned By - 3 minutes 35 seconds Assigned By - 1 day, 1 hour. I would appreciate if one could give me the PLAIN QUERY along with PHP code to embed it too.

    Read the article

  • Teradata equivalent of persisted computed column (in SQL Server)

    - by Cade Roux
    We have a few tables with persisted computed columns in SQL Server. Is there an equivalent of this in Teradata? And, if so, what is the syntax and are there any limitations? The particular computed columns I am looking at conform some account numbers by removing leading zeros - an index is also created on this conformed account number: ACCT_NUM_std AS ISNULL(CONVERT(varchar(39), SUBSTRING(LTRIM(RTRIM([ACCT_NUM])), PATINDEX('%[^0]%', LTRIM(RTRIM([ACCT_NUM])) + '.' ), LEN(LTRIM(RTRIM([ACCT_NUM]))) ) ), '' ) PERSISTED With the Teradata TRIM function, the trimming part would be a little simpler: ACCT_NUM_std AS COALESCE(CAST(TRIM(LEADING '0' FROM TRIM(BOTH FROM ACCT_NUM))) AS varchar(39)), '' ) I guess I could just make this a normal column and put the code to standardize the account numbers in all the processes which insert into the table. We did this to put the standardization code in one place.

    Read the article

  • How to put a newline into a column header in an xtable in R

    - by PaulHurleyuk
    I have a dataframe that I am putting into a sweave document using xtable, however one of my column names is quite long, and I would like to break it over two lines to save space calqc_table<-structure(list(RUNID = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), ANALYTEINDEX = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), ID = structure(1:11, .Label = c("Cal A", "Cal B", "Cal C", "Cal D", "Cal E", "Cal F", "Cal G", "Cal H", "Cal High", "Cal Low", "Cal Mid"), class = "factor"), mean_conc = c(200.619459644855, 158.264703128903, 102.469121407733, 50.3551544728544, 9.88296440865076, 4.41727762501703, 2.53494715706024, 1.00602831741361, 199.065054555735, 2.48063347296935, 50.1499780776199), sd_conc = c(2.3275711264554, NA, NA, NA, NA, NA, NA, 0.101636943231162, 0, 0, 0), nrow = c(3, 1, 1, 1, 1, 1, 1, 3, 2, 2, 2)), .Names = c("Identifier of the Run within the Study", "ANALYTEINDEX", "ID", "mean_conc", "sd_conc", "nrow"), row.names = c(NA, -11L ), class = "data.frame") calqc_xtable<-xtable(calqc_table) I have tried putting a newline into the name, but this didn't seem to work names(calqc_table)[1]<-"Identifier of the \nRun within the Study" Is there a way to do this ? I have seen someone suggest using the latex function from the hmisc package to manually iterate over the table and write it out in latex manually, including the newline, but this seems like a bit of a faf !

    Read the article

  • How to merge two tables based on common column and sort the results by date

    - by techiepark
    Hello friends, I have two mysql tables and i want to merge the results of these two tables based on the common column rev_id. The merged results should be sorted by the date of two tables. Please help me. CREATE TABLE `reply` ( `id` int(3) NOT NULL auto_increment, `name` varchar(25) NOT NULL default '', `member_id` varchar(45) NOT NULL, `rev_id` int(3) NOT NULL default '0', `description` text, `post_date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, `flag` char(2) NOT NULL default 'N', PRIMARY KEY (`id`), KEY `member_id` (`member_id`) ) ENGINE=MyISAM; CREATE TABLE `comment` ( `com_id` int(8) NOT NULL auto_increment, `rev_id` int(5) NOT NULL default '0', `member_id` varchar(50) NOT NULL, `comm_desc` text NOT NULL, `date_created` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, PRIMARY KEY (`com_id`), KEY `member_id` (`member_id`) ) ENGINE=MyISAM;

    Read the article

  • MySQL top count({column}) with a limit

    - by Josh K
    I have a table with an ip address column. I would like to find the top five addresses which are listed. Right now I'm planning it out the following: Select all distinct ip addresses Loop through them all saying count(id) where IP='{ip}' and storing the count List the top five counts. Downsides include what if I have 500 ip addresses. That's 500 queries I have to run to figure out what are the top five. I'd like to build a query like so select ip from table where 1 order by count({distinct ip}) asc limit 5

    Read the article

  • Table and Column names causing problems

    - by craig
    I have an issue when the T4 linq templates generate the classes for my MySql db using subsonic 3. It looks like one of our table names "operator" is causing problems in the Context.cs generated class. In the following line of code in Context.cs Visual Studio sees <operator> as a c# operator and generates a compilation error of "Type expected" public Query<operator> operators { get; set; } Is there anyway I can work around this without having to rename my database table and column names? For example hard coding something in Settings.ttinclude to use or map different names to specific db tables and columns?

    Read the article

  • SQL Server won't perform regular expression validation on XML column

    - by Kirk Broadhurst
    Hi I have an XML column in my table which contains this xsd snippet: <xsd:element name="Postcode" minOccurs="0"> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:pattern value="^[0-9]{4}$" /> </xsd:restriction> </xsd:simpleType> </xsd:element> The regular expression should require a string containing 4 numerical digits. It validates perfectly in Visual Studio and is a correct regular expression. SQL Server, on the other hand, won't accept it. The error message I receive is: XML Validation: Invalid simple type value: '1234'. Location: / * : Donor[1]/*:Postcode[1]. I have an email address regex working fine, but can't get this simple numerical regex to work.

    Read the article

  • jqGrid formatter and sortable column - doesn't sort

    - by HeavyWave
    I am using a custom formatter for my jqGrid columnModel and I can't get sorting to work with formatter functions. If I remove formatter column sorts normally. colModel: [ { name: 'status', index: 'status', width: 18, sorttype: 'int', align: 'center', formatter: function(cellvalue, options, rowObject) { return cellvalue == 1 ? "<img src='images/agent_green_s.png' alt='Ready' title='Ready' />" : cellvalue == 3 ? "<img src='images/agent_red_s.png' alt='Busy' title='Busy' />" : "<img src='images/agent_orange_s.png' alt='Pending Ready' title='Pending Ready' />"; } How do I get sorting to work properly?

    Read the article

  • Linq to sql Error "Data at the root level is invalid " for nullable xml column

    - by Mukesh
    I have Created a table like CREATE TABLE [dbo].[tab1]( [Id] [int] NOT NULL, [Name] [varchar](100) NOT NULL, [Meta] [xml] NULL, CONSTRAINT [PK_tab1] PRIMARY KEY CLUSTERED ( [Id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] When I am doing linq to sql query to fetch a data it throw an error "data at the root level is invalid linq". In further investigation I come to know that the meta column is null in that case. In real it is nullable Do I have to remove the nullable and set some blank root node as default or there is some another way to get rid of the error. My linq Query which throws error var obj1= (from obj in dbContext.tab1s where obj.id== 123 select obj).FirstOrDefault<Tab1>();

    Read the article

  • Saving a huge dataset into SQL table in a XML column - MS SQL, C#.Net

    - by NLV
    Hello all I'm having a requirement where i've to save a dataset which has multiple tables in it in a sql table XML column by converting into an XML. The problem is that in some cases the dataset grows extremely huge and i get OutOfMemoryException. What i basically do is that i convert the dataset into an xml file and save it in the local disk and then load the XML again and send it as a stored procedure parameter. But when i write the dataset xml into the disk the file sizes over 700 Mb and when i load it in the XMLDocument object in memory i get OutOfMemoryException. How can get the dataset xml without saving it in a file and re-reading it again? Thank You NLV

    Read the article

  • Efficiency of checking for null varbinary(max) column ?

    - by Moe Sisko
    Using SQL Server 2008. Example table : CREATE table dbo.blobtest (id int primary key not null, name nvarchar(200) not null, data varbinary(max) null) Example query : select id, name, cast((case when data is null then 0 else 1 end) as bit) as DataExists from dbo.blobtest Now, the query needs to return a "DataExists" column, that returns 0 if the blob is null, else 1. This all works fine, but I'm wondering how efficient it is. i.e. does SQL server need to read in the whole blob to its memory, or is there some optimization so that it just does enough reads to figure out if the blob is null or not ? (FWIW, the sp_tableoption "large value types out of row" option is set to OFF for this example).

    Read the article

  • Rails: translations for table's column.

    - by Andrew
    In rails application I have two models: Food and Drink. Both food and drink have a name, which has to be stored in two languages. How do I better realize translations for theese tables? First solution I realized was to replace name column with name_en and name_ru. Another solution is to encode with YAML hash like { :en => 'eng', :ru => 'rus' } and store yaml as a name. What would you recommend, assuming content is not static? Maybe there's good article?

    Read the article

  • Minimum & Maximum Values in Crystal Reports 2008 Column

    - by GregD
    Say I have this column returned in a command for Crystal: deposit_no 123 130 125 124 126 127 128 129 and I need to have this in the report title: Includes deposits between 123 - 130 I've tried a running formula for minimum and maximum and they aren't returning the correct values no matter how I manipulate them. I've tried evaluate for every record, on change of the deposit_no field, etc. I have no grouping on this report. Edited to add: While I preferred to handle this on the CR side of things, I changed my command to include what mson wrote below. So technically, mson had the correct answer.

    Read the article

  • How split a column in two colunms in pandas

    - by user1345283
    I have el next dataframe data=read_csv('enero.csv') data Fecha DirViento MagViento 0 2011/07/01 00:00 318 6.6 1 2011/07/01 00:15 342 5.5 2 2011/07/01 00:30 329 6.6 3 2011/07/01 00:45 279 7.5 4 2011/07/01 01:00 318 6.0 5 2011/07/01 01:15 329 7.1 6 2011/07/01 01:30 300 4.7 7 2011/07/01 01:45 291 3.1 How to split the column Fecha in two columns,for example, get a dataframe as follows: Fecha Hora DirViento MagViento 0 2011/07/01 00:00 318 6.6 1 2011/07/01 00:15 342 5.5 2 2011/07/01 00:30 329 6.6 3 2011/07/01 00:45 279 7.5 4 2011/07/01 01:00 318 6.0 5 2011/07/01 01:15 329 7.1 6 2011/07/01 01:30 300 4.7 7 2011/07/01 01:45 291 3.1 I am using pandas for to read data I try to calculate daily averages from a monthly database has daily data recorded every 15 minutes. To do this, use pandas and grouped the columns: Date and Time for get a dataframe as follow: Fecha Hora 2011/07/01 00:00 -4.4 00:15 -1.7 00:30 -3.4 2011/07/02 00:00 -4.5 00:15 -4.2 00:30 -7.6 2011/07/03 00:00 -6.3 00:15 -13.7 00:30 -0.3 with this look, I get the following grouped.mean() Fecha DirRes 2011/07/01 -3 2011/07/02 -5 2011/07/03 -6

    Read the article

  • How do I allow edit only a particular column in datagridview in windows application using C#

    - by cmrhema
    Hi, I want to enable only two columns in the DataGridview to be able to edit. The others should not be allowed to edit. Further I am not directly linking to datasource; I will be doing some thing like this way DataTable dt = new DataTable(); dt.Columns.Add("Email"); dt.Columns.Add("email1"); for (int i = 0; i < 5; i++) { DataRow dr = dt.NewRow(); dr["Email"] = i.ToString(); dr["email1"] = i.ToString() + "sdf"; dt.Rows.Add(dr); } BindingSource bs = new BindingSource(); bs.DataSource = dt; dataGridView1.DataSource = bs; So which property should I set, that will enable only one column say Email(in the above eg) to be editable. Thanks

    Read the article

  • CFGRID - replace data store or filter on more than one column

    - by Casuzen
    ColdFusion 8 I have a cfgrid that that is based on a query. It is not bound to a cfc function because I want a scrolling grid, not a paged grid (you must supply the page number and page size if you use BIND).. I can figure out how to make it filter on one column by using the following code, but I really need to filter on three columns... grid.getDataSource().filter("OT_MILESTONE",t1); Adding more to the filter string does not do the trick...it ignores anything more than the first pair of values.. so..I thought if I called a function that passes the three values and returned the query results to me, I could replace the Data Store for the grid..but I cannot figure out the syntax to get it to replace. The returned variable for the query has the following format: {"COLUMNS":["SEQ_KEY","ID","OT_MILESTONE"],"DATA":[[63677,"x","y"]]} Any ideas?

    Read the article

< Previous Page | 54 55 56 57 58 59 60 61 62 63 64 65  | Next Page >