Search Results

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

Page 132/489 | < Previous Page | 128 129 130 131 132 133 134 135 136 137 138 139  | Next Page >

  • using NEWSEQUENTIALID() with UPDATE Trigger

    - by Ram
    I am adding a new GUID/Uniqueidentifier column to my table. ALTER TABLE table_name ADD VersionNumber UNIQUEIDENTIFIER UNIQUE NOT NULL DEFAULT NEWSEQUENTIALID() GO And when ever a record is updated in the table, I would want to update this column "VersionNumber". So I create a new trigger CREATE TRIGGER [DBO].[TR_TABLE_NAMWE] ON [DBO].[TABLE_NAME] AFTER UPDATE AS BEGIN UPDATE TABLE_NAME SET VERSIONNUMBER=NEWSEQUENTIALID() FROM TABLE_NAME D JOIN INSERTED I ON D.ID=I.ID/* some ID which is used to join*/ END GO But just realized that NEWSEQUENTIALID() can only be used with CREATE TABLE or ALTER TABLE. I got this error The newsequentialid() built-in function can only be used in a DEFAULT expression for a column of type 'uniqueidentifier' in a CREATE TABLE or ALTER TABLE statement. It cannot be combined with other operators to form a complex scalar expression. Is there a workaround for this ? Edit1: Changing NEWSEQUENTIALID() to NEWID() in the trigger solves this, but I am indexing this column and using NEWID() would be sub-optimal

    Read the article

  • SQL server 2005 query not running

    - by Aayushi
    Hi, Before posting this question, I have tried so many things but that was not helpful for me. I want to rename the column of table at sql server 2005, following query I have run at sql server2005: 1) ALTER TABLE Details RENAME COLUMN AccountID TO UID; but it gives me the error: Incorrect syntax near the keyword 'COLUMN'. 2)I have added one new column in the table by query: ALTER TABLE Details ADD BID uniqueidentifier; and then I want to set the coulmn property to not null . How can i do that? Thanks in advance AS

    Read the article

  • SQL: Is there a more efficient way to calculate elapsed hours, minutes, seconds?

    - by hamlin11
    I'm using Computed Columns to provide me with the following information: Hours, Minutes, and Seconds between a Start DateTime and Finish DateTime (Where Minutes and Seconds are between 0 and 59 and Hours can be any value 0 or greater) Computed Column for Seconds: datediff(second,[Start],[Finish]) % 60 Computed Column for Minutes: floor(datediff(second,[Start],[Finish]) / 60.0) % 60 Computed Column for Hours: floor(datediff(second,[Start],[Finish]) / 3600.0) Here's the table for reference Note: I'm also calculating TotalElapsedSeconds, TotalElapsedMinutes, and TotalElapsedHours in other computed columns, but those are easy. I just feel like I might be missing out on a nice built in function in SQL.

    Read the article

  • Transaction within IF THEN ELSE doesn't commit

    - by boris callens
    In my TSQL script I have an IF THEN ELSE structure that checks if a column already exists. If not it creates the column and updates it. IF NOT EXISTS( SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'tableName' AND COLUMN_NAME = 'columnName')) BEGIN BEGIN TRANSACTION ALTER TABLE tableName ADD columnName int NULL COMMIT BEGIN TRANSACTION update tableName set columnName = [something] from [subquery] COMMIT END This doesn't work because the column doesn't exist after the commit. Why doesn't the COMMIT commit?

    Read the article

  • [Flex] Using same set of columns in AdvancedDataGrid in a TabBar

    - by user283403
    I have a TabBar control which will show an AdvancedDataGrid with same set of columns on different tabs, i am doing this so that i can show similar data on different tab pages. Column heading will be the same on all grids, is there a way I can put all column headings in an array and set that as columns of data grid? I tried setting the columns property but it doesn't work. Also I need to set ID property for a single column in the grid to set it the treecolumn so one column must have individual id field too.

    Read the article

  • Alter multiple tables' columns length

    - by gdoron
    So, we just found out that 254 tables in our Oracle DBMS have one column named "Foo" with the wrong length- Number(10) instead of Number(3). That foo column is a part from the PK of the tables. Those tables have other tables with forigen keys to it. What I did is: backed-up the table with a temp table. Disabled the forigen keys to the table. Disabled the PK with the foo column. Nulled the foo column for all the rows. Restored all the above But now we found out it's not just couple of tables but 254 tables. Is there an easy way, (or at least easier than this) to alter the columns length? P.S. I have DBA permissions.

    Read the article

  • hibernate empty collection in component

    - by Jurgen H
    I have a component mapped using Hibernate. If all fields in the component in the database are null, the component itself is set to null by hibernate. This is the expected behavior and also what I need. The problem I have, is that when I add a bag to that component, the bag is initialized to an empty list. This means the component has a non null value... resulting in the component being created. Any idea how to fix this? <class name="foo.bar.Entity" table="Entity"> <id name="id" column="id"> <generator class="native" /> </id> <property name="departure" column="departure_time" /> <property name="arrival" column="arrival_time" /> <component name="statistics"> <bag name="linkStatistics" lazy="false" cascade="all" > <key column="entity_id" not-null="true" /> <one-to-many class="foo.bar.LinkStatistics" /> </bag> <property name="loggedTime" column="logged_time" /> ... </component> A criteria with Restirctions.isNull("statistics") does return the expected values.

    Read the article

  • Add/Edit Columns in DataBound DataGrid

    - by Dave
    I've got a datagrid that is databound from a database table. How do I: a) Edit the displayed value for a column using the values from other columns in the row? (For example, display a URL like: <a href="/url?param=columnA">columnB</a> where columnA is the value from column A and columnB is the value from columnB) b) Add an additional column using values from the other columns (similar to a.)

    Read the article

  • VBA for filtering columns

    - by Ampi Severe
    I have a big database-like sheet, first row contains headers. I would like a subset of rows of this table based on column values. Two issues: 1) VBA-wise I would like to loop through the columns, when the values for all necessary columns all match, copy the entire row into a new sheet. 2) The subset of rows is based on a list. This should be the first column to be looped through. For example I want all rows where the value in column A is equal to one of the values in my list. Is there any possibility to autofilter strings based on a list (column) of strings? EDIT Thanks to @Doug Glancy the autofiltering works now, so I've removed my (horrible) code and issue 1 is solved.

    Read the article

  • MS SQL Server Dates Excel

    - by KillerSnail
    I have data this is linked from SQL Server into an excel document. The column format on the SQL Server is datetime2. When I get the data via an ODBC connection it comes across as a string? I tried using CAST(column AS DATE ) but that didn't work. I tried reformatting via CONVERT(VARCHAR(10), column, 103) as well but that didn't work. I tried retrieving the data via Microsoft query as well but that didn't work. At the moment I am using VBA code like: While (ActiveCell.Value <> "") ActiveCell.Value = DATEVALUE(ActiveCell.Value) ActiveCell.Offset(1,0).Activate Wend and looping through each column that needs this treatment but 100000 rows in multiple columns takes forever to loop through. Are there any alternatives?

    Read the article

  • rails: best way to store comments in mysql

    - by ciss
    Hello. Okay i have two models: posts and comments. as you can think comments has column :post_id. My models Comments belongs_to :post Post has_many :comments So, this is pretty simple association but i have some problems with ordering comments. at first time, when i create my comments migration file i just add column :position. This column indicate comment position in the post. But now i think what where is more good way to do this. so i can't make my choise: 1) uses t.column :datatime :created_at, :default = Time.now() 2) or use timestamps? this is undiscovered for me, please tell me about your exp.

    Read the article

  • Set PdfPTable columns width iText

    - by Mr CooL
    I've a PdfPTable created in my Java program, Is there any way to actually set the width of specific column for the PdfPTable????? For instance, First column to be 5% width, second column to be 20% and etc. Urgent help please if anyone knows the way. Thanks in advance.

    Read the article

  • Inner join 2 tables one to many 2 where clauses

    - by user2892350
    I'm a relative rookie at this,so please bear with me... I have 2 tables: OrderDetail and OrderMaster...both have a column named SalesOrder. OrderDetail table has multiple rows per unique SalesOrder. OrderMaster table has one row per unique SalesOrder. OrderDetail has a column named LineType. OrderMaster has a column named OrderStatus. I want to select all records from OrderDetail that have a LineType of "1" AND whose matching SalesOrder line in the OrderMaster table has a OrderStatus column value of "4". In plain English, orders with a Status 4 are open and ready to ship, LineType value of 1 means the Detail Line is a product code. How should this query be structured? It's going into VS 2008 (VB). Many thanks in advance!!! Mike

    Read the article

  • Problem persisting inheritance tree

    - by alaiseca
    I have a problem trying to map an inheritance tree. A simplified version of my model is like this: @MappedSuperclass @Embeddable public class BaseEmbedded implements Serializable { @Column(name="BE_FIELD") private String beField; // Getters and setters follow } @MappedSuperclass @Embeddable public class DerivedEmbedded extends BaseEmbedded { @Column(name="DE_FIELD") private String deField; // Getters and setters follow } @MappedSuperclass public abstract class BaseClass implements Serializable { @Embedded protected BaseEmbedded embedded; public BaseClass() { this.embedded = new BaseEmbedded(); } // Getters and setters follow } @Entity @Table(name="MYTABLE") @Inheritance(strategy=InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name="TYPE", discriminatorType=DiscriminatorType.STRING) public class DerivedClass extends BaseClass { @Id @Column(name="ID", nullable=false) private Long id; @Column(name="TYPE", nullable=false, insertable=false, updatable=false) private String type; public DerivedClass() { this.embedded = new DerivedClass(); } // Getters and setters follow } @Entity @DiscriminatorValue("A") public class DerivedClassA extends DerivedClass { @Embeddable public static NestedClassA extends DerivedEmbedded { @Column(name="FIELD_CLASS_A") private String fieldClassA; } public DerivedClassA() { this.embedded = new NestedClassA(); } // Getters and setters follow } @Entity @DiscriminatorValue("B") public class DerivedClassB extends DerivedClass { @Embeddable public static NestedClassB extends DerivedEmbedded { @Column(name="FIELD_CLASS_B") private String fieldClassB; } public DerivedClassB() { this.embedded = new NestedClassB(); } // Getters and setters follow } At Java level, this model is working fine, and I believe is the appropriate one. My problem comes up when it's time to persist an object. At runtime, I can create an object which could be an instance of DerivedClass, DerivedClassA or DerivedClassB. As you can see, each one of the derived classes introduces a new field which only makes sense for that specific derived class. All the classes share the same physical table in the database. If I persist an object of type DerivedClass, I expect fields BE_FIELD, DE_FIELD, ID and TYPE to be persisted with their values and the remaining fields to be null. If I persist an object of type DerivedClass A, I expect those same fields plus the FIELD_CLASS_A field to be persisted with their values and field FIELD_CLASS_B to be null. Something equivalent for an object of type DerivedClassB. Since the @Embedded annotation is at the BaseClass only, Hibernate is only persisting the fields up to that level in the tree. I don't know how to tell Hibernate that I want to persist up to the appropriate level in the tree, depending on the actual type of the embedded property. I cannot have another @Embedded property in the subclasses since this would duplicate data that is already present in the superclass and would also break the Java model. I cannot declare the embedded property to be of a more specific type either, since it's only at runtime when the actual object is created and I don't have a single branch in the hierarchy. Is it possible to solve my problem? Or should I resignate myself to accept that there is no way to persist the Java model as it is? Any help will be greatly appreciated.

    Read the article

  • Sorting Multidimensional Array with Javascript: Integers

    - by tkm256
    I have a 2D array called "results." Each "row" array in results contains both string and integer values. I'm using this script to sort the array by any "column" on an onclick event: function sort_array(results, column, direction) { var sorted_results = results.sort(value); function value(a,b) { a = a[column]; b = b[column]; return a == b ? 0 : (a < b ? -1*direction : 1*direction) } } This works fine for the columns with strings. But it treats the columns of integers like strings instead of numbers. For example, the values 15, 1000, 200, 97 would be sorted 1000, 15, 200, 97 if "ascending" or 97, 200, 15, 1000 "descending." I've double-checked the typeof the integer values, and the script knows they're numbers. How can I get it to treat them as such?

    Read the article

  • solving css validation errors

    - by pradeep
    http://validator.w3.org/check?uri=http%3A%2F%2Fratingscorner.com%2Fproduct_rating.php%3Falias%3DRashtreeya-Vidyalaya-College-of-Engineering-Mysore-Road-Bangalore%26product%3Dcolleges&charset=%28detect+automatically%29&doctype=Inline&group=0&ss=1&st=1&outline=1&No200=1&verbose=1 hi guys, i solved mots of my css errors . there are few errors which i am unable to fix. can some one please help me on it. 1.Warning Line 440, Column 1121: cannot generate system identifier for general entity "p" and similar errors 2.Error Line 113, Column 52: document type does not allow element "input" here; missing one of "p", "h1", "h2", "h3", "h4", "h5", "h6", "div", "pre", "address", "fieldset", "ins", "del" start-tag 3.Error Line 441, Column 37752: document type does not allow element "tfoot" here Error Line 440, Column 80: EntityRef: expecting ';'

    Read the article

  • C# : Problem in creating diffrent types of columns in a gridview

    - by Royson
    My windows form application has a grid view control with filename as a default column. User should create a column of following types Text, Number, Currency, Combo Box, Check Box, Radio Button ,Date time type (should display DateTimePicker control) and Hyper Link type. After that i want to pass all rows to next screen for further processing. We can create a column of these types in a grid view but how can i store it in a data table so that i can pass it to next screen. Or should i create a column in a data table and then assign data table to grid view by gridview.DataSource = dt; but can we create a these types of columns in a data table. I am so confused!! Please help me to solve this problem. Thanks

    Read the article

  • hibernate annotation bi-directional mapping

    - by smithystar
    I'm building a web application using Spring framework and Hibernate with annotation and get stuck with a simple mapping between two entities. I'm trying to create a many-to-many relationship between User and Course. I followed one of the Hibernate tutorials and my implementation is as follows: User class: @Entity @Table(name="USER") public class User { private Long id; private String email; private String password; private Set<Course> courses = new HashSet<Course>(0); @Id @GeneratedValue @Column(name="USER_ID") public Long getId() { return id; } public void setId(Long id) { this.id = id; } @Column(name="USER_EMAIL") public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } @Column(name="USER_PASSWORD") public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } @ManyToMany(cascade = CascadeType.ALL) @JoinTable(name = "USER_COURSE", joinColumns = { @JoinColumn(name = "USER_ID") }, inverseJoinColumns = { @JoinColumn(name = "COURSE_ID") }) public Set<Course> getCourses() { return courses; } public void setCourses(Set<Course> courses) { this.courses = courses; } } Course class: @Entity @Table(name="COURSE") public class Course { private Long id; private String name; @Id @GeneratedValue @Column(name="COURSE_ID") public Long getId() { return id; } public void setId(Long id) { this.id = id; } @Column(name="NAME") public String getName() { return name; } public void setName(String name) { this.name = name; } } The problem is that this implementation only allows me to go one way user.getCourses() What do I need to change, so I can go in both directions? user.getCourses() course.getUsers() Any help would be appreciated.

    Read the article

  • Saving data that is in a table efficiently and also is easy to retrieve and echo back out

    - by Harry
    Information I currently have a table which image is below, Problem I have made this table using ul & li Here is the code http://jsfiddle.net/8j2qe/1/ Question What would be the best way of storing the data in the image and easily displaying it? Keeping in mind that each column can only have 1 entry. Thank you! And any questions will be answered ASAP! EDIT Sorry, I dont think I was clear enough in my initial question. What I am asking is, what is the best way to store and then display this type of data. I want to DISPLAY data from my database to show like it would in the image. Should I have a column in my database for each column on the table, then say either A,B,C or D depending on what column it is in but then how would I display it using PHP in my code provided? Im struggling to find a good way of explaining this, I am sorry.

    Read the article

  • Problem with DataGrid_CellFormatting event to set default value

    - by Royson
    Hi, I have created an applicationto display list of files. it also provide user interface for adding new column to a gridview. DataGridViewTextBoxColumn txtBoxColumn = new DataGridViewTextBoxColumn(); txtBoxColumn.Name = columnName; txtBoxColumn.HeaderText = columnName; g_dataGridView.Columns.Add(txtBoxColumn); User will create some custom type column therefore i am adding column directly to grid. I am also able to set its default value before adding for this i am using DataGrid_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { if (colIndexWithDefaultValue.Count > 0) { if (colIndexWithDefaultValue.Contains(e.ColumnIndex)) { g_dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = colIndexWithDefaultValue[e.ColumnIndex]; } } } where colIndexWithDefaultValue is list of columns with its default value. It is able to show newly created column with default value. But values are getting set for currently visible rows. To set value for all rows i have to do scrolling. So, how do i overcome this problem...

    Read the article

  • Excel: VLOOKUP that returns true or false?

    - by Svish
    In Excel we have the VLOOKUP function that looks for a value in a column in a table and then returns a value from a given column in that table if it finds something. If it doesn't, it produces an error. Is there a function that just returns true or false depending on if the value was found in a column or not?

    Read the article

  • Which index is used in select and why?

    - by Lukasz Lysik
    I have the table with zip codes with following columns: id - PRIMARY KEY code - NONCLUSTERED INDEX city When I execute query SELECT TOP 10 * FROM ZIPCodes I get the results sorted by id column. But when I change the query to: SELECT TOP 10 id FROM ZIPCodes I get the results sorted by code column. Again, when I change the query to: SELECT TOP 10 code FROM ZIPCodes I get the results sorted by code column again. And finally when I change to: SELECT TOP 10 id,code FROM ZIPCodes I get the results sorted by id column. My question is in the title of the question. I know which indexes are used in the queries, but my question is, why those indexes are used? I the second query (SELECT TOP 10 id FROM ZIPCodes) wouldn't it be faster if the clusteder index was used? How the query engine chooses which index to use?

    Read the article

< Previous Page | 128 129 130 131 132 133 134 135 136 137 138 139  | Next Page >