calculated-columns

Counting Folder Depth with PowerShell

江枫思渺然 提交于 2020-02-28 07:40:11
问题 1. Code Description alias how it is intended to work User enters a path to a directory in PowerShell. Code checks if any folder within the declared directory contains no data at all. If so, the path of any empty folder will be shown on the prompt to the user and eventually removed from the system. 2. The Issue alias what I am struggling with The code I just wrote doesn't count the depth of a folder hierarchy as I would expect (the column in the output table is blank). Besides that, the

Deal with awkwardness from adding timestamp column to mysql table

落爺英雄遲暮 提交于 2020-02-25 08:36:34
问题 I have a very large table that I want to add a timestamp column to. It is a table that gets a lot more updates than inserts. I am trying to figure out a way to do this without taking the table out of production for a significant amount of time and it has me in knots. I can do: alter table stuff add column mod_time timestamp; Well, I could do this and then the table is locked for 3-5 hours. Not a happy time for users. For adding a varchar column, for example, I could create a new table, add

Create a computed column and round

风格不统一 提交于 2020-01-30 06:34:27
问题 I have 3 numeric(18,2) columns in my table. I want to create a fourth column that is computed . I created the computed column in SSMS as numeric (18,2) just like the other 3 columns. When I run a SELECT against my new column, it computes it fine, but it's not rounded to two decimal places. I've tried using the ROUND function inside my computed column definition but that didn't work. It reset my data type to numeric (38,6) and now won't let me change it. My new column definition is ((Length *

spotfire: search a column of another table

谁都会走 提交于 2020-01-25 04:09:05
问题 I'm trying to make a calculated column in Spotfire, where a specific value has to be present in a column of another table before a new value is assigned. My expression looks like this: If(Find('Specific value first table',**'present in second table'**) is Null, 0, 'New Value') I have no idea how to involve this second table in my search, does anyone has any idea? Thanks in advance! 回答1: You won't be able to reference another table when creating a calculated column. However, I think we can

SQL Server: Bulk Insert into table with computed column

萝らか妹 提交于 2020-01-24 22:23:29
问题 I try to insert data from a textfile into a SQL Server 2016 table with a computed column with bcp. My bcp command: bcp Test.dbo.myFirstImport IN D:\myFirstImport.txt -f D:\myFirstImport.xml –T My table: CREATE TABLE [dbo].[MyFirstImport]( [PersonID] [smallint] NULL, [FirstName] [varchar](25) NULL, [LastName] [varchar](30) NULL, [BirthDate] [date] NOT NULL, [YearMonthCom] AS (datepart(year,[BirthDate])*(100)+datepart(month,[BirthDate])) PERSISTED ) ON [PRIMARY] My Data (tab separated): 1

Entity Framework Code First: How to map SQL Server's computed columns into CF model?

你。 提交于 2020-01-24 21:29:10
问题 Is it possible to map computed columns into Code First model? I'd like to define computed columns with SQL Server and then map them as properties inside my CF model. Thanks in advance Best Regards 回答1: Use the DatabaseGenerated attribute with DatabaseGeneratedOption.Computed as the value [DatabaseGenerated(DatabaseGeneratedOption.Computed)] public string Foo { get; set; } 回答2: Not sure how you would do computed columns without using a view, and you cannot use views in EF Code First (you can

PostgreSQL: creating a generated column

十年热恋 提交于 2020-01-16 16:50:41
问题 Goal: My goal is to create a new column called paymentPrice which is the sum of receiptPrice , platformFee , delivererFee (which needs to display the sum of the current values). From reading the docs I thought using a generated column would be thebest way to achieve this. Syntax: ALTER TABLE "orders" ADD "paymentPrice" FLOAT GENERATED ALWAYS AS (orders."receiptPrice" + orders."platformFee" + orders."delivererFee") VIRTUAL;' Error: My current syntax results in the following error, but I can't

PostgreSQL: creating a generated column

人走茶凉 提交于 2020-01-16 16:50:29
问题 Goal: My goal is to create a new column called paymentPrice which is the sum of receiptPrice , platformFee , delivererFee (which needs to display the sum of the current values). From reading the docs I thought using a generated column would be thebest way to achieve this. Syntax: ALTER TABLE "orders" ADD "paymentPrice" FLOAT GENERATED ALWAYS AS (orders."receiptPrice" + orders."platformFee" + orders."delivererFee") VIRTUAL;' Error: My current syntax results in the following error, but I can't

Computed column expression

白昼怎懂夜的黑 提交于 2020-01-16 13:17:30
问题 I have a specific need for a computed column called ProductCode ProductId | SellerId | ProductCode 1 1 000001 2 1 000002 3 2 000001 4 1 000003 ProductId is identity, increments by 1. SellerId is a foreign key. So my computed column ProductCode must look how many products does Seller have and be in format 000000. The problem here is how to know which Sellers products to look for? I've written have a TSQL which doesn't look how many products does a seller have ALTER TABLE dbo.Product ADD

calculation the difference for same column for the specific rows in Spotfire

淺唱寂寞╮ 提交于 2020-01-10 20:10:53
问题 I have a problem about the difference calculation for the rows using calculated column in Spotfire. I am wondering if it is possible to create a calculated column that will count the difference between the current row with the next row which have different attribute. A sample table could be like this: the result could be like this: the basic row is: When type =1, then calculate the difference between its current value and its next nearest row which type =0, then add the result to a new