tsql

How to update data as json array and select data as json array in sql server

心不动则不痛 提交于 2020-03-22 09:05:20
问题 I am new in SQL server 2017 for JSON result. I am storing JSON array in one column in my table. I am saving id's array in that table, but i want to update its relative text from other table, so please help me in this. create table #subjectList(subjectID int identity(1,1),subjectName varchar(50)) insert into #subjectList(subjectName) select 'Math' union all select 'English' union all select 'Hindi' union all select 'PC' union all select 'Physics' select * from #subjectList Create table

Ordering by a field not in the select statement in SQL

时光怂恿深爱的人放手 提交于 2020-03-16 05:49:41
问题 I need to create a query that pulls only the customer_no column (because the software restrictions are as such, and I can't code it externally). But I need to be able to sort the data by create_dt (in reverse) column. The code/SQL is restricting me in using the following because in order to sort by something that data has to appear int the select statement. I can't have it appear there – is there any way around this? Select Distinct top 3500 a.customer_no From T_CUSTOMER a WITH (NOLOCK) JOIN

SqlCommand.Prepare method requires all parameters to have an explicitly set type

坚强是说给别人听的谎言 提交于 2020-03-16 05:27:42
问题 I have the following snippet of code in my WCF web service that builds a set of where conditions according to the formatting of the values of a provided dictionary. public static Dictionary<string, string>[] VehicleSearch(Dictionary<string, string> searchParams, int maxResults) { string condition = ""; foreach (string key in searchParams.Keys) { //Split out the conditional in case multiple options have been set (i.e. SUB;OLDS;TOY) string[] parameters = searchParams[key].Split(';'); if

SqlCommand.Prepare method requires all parameters to have an explicitly set type

女生的网名这么多〃 提交于 2020-03-16 05:27:20
问题 I have the following snippet of code in my WCF web service that builds a set of where conditions according to the formatting of the values of a provided dictionary. public static Dictionary<string, string>[] VehicleSearch(Dictionary<string, string> searchParams, int maxResults) { string condition = ""; foreach (string key in searchParams.Keys) { //Split out the conditional in case multiple options have been set (i.e. SUB;OLDS;TOY) string[] parameters = searchParams[key].Split(';'); if

Nhibernate subquery with multiple columns join

扶醉桌前 提交于 2020-03-12 05:47:54
问题 I have database structure for Plans and PlanVersions in following relationship: +------+ +-------------+ | Plan | --------------> | PlanVersion | +------+ 1 (1..n) +-------------+ PlanVersion is version table tracking all version changes and it have ActiveFromData and ActiveToData columns show us when was this version active. Plan also can have SubPlans which can change in time so PlanVersion also have ParrentPlanId column which tell us what was current subplan for version. What i want is to

Performing an operation on the result of a query, without saving a table

江枫思渺然 提交于 2020-03-04 18:35:30
问题 I'm very new to SQL and T-SQL, so please forgive any mistakes in terminology or if the answer is obvious - I don't even know where to start googling for the solution to this problem. I only have SELECT permission on a T-SQL server. I have a query that pulls a bunch of information based on an event with a Start Date (DATETIME) and End Date (DATETIME). I want to have a calculated column in my query result that indicates whether the person was just involved in back-to-back events. So, something

How to get the last records for a combination of 2 columns?

柔情痞子 提交于 2020-03-02 08:04:33
问题 I have a situation which I think can be compared to services like CamelCamelCamel, Keepa and so on. Lets say I track the price of an article on each day for a couple of countries. So my table, lets call it Trend , would look something like this Id Created ArticleId Country Price ------------------------------------------------- 01 19/11/05 452 US 45.90 02 19/11/05 452 CA 52.99 03 19/11/05 452 MX 99.99 04 19/11/06 452 US 20.00 05 19/11/06 452 CA 25.00 06 19/11/06 452 MX 50.00 ... 97 19/11/05

How to get the last records for a combination of 2 columns?

只愿长相守 提交于 2020-03-02 08:03:19
问题 I have a situation which I think can be compared to services like CamelCamelCamel, Keepa and so on. Lets say I track the price of an article on each day for a couple of countries. So my table, lets call it Trend , would look something like this Id Created ArticleId Country Price ------------------------------------------------- 01 19/11/05 452 US 45.90 02 19/11/05 452 CA 52.99 03 19/11/05 452 MX 99.99 04 19/11/06 452 US 20.00 05 19/11/06 452 CA 25.00 06 19/11/06 452 MX 50.00 ... 97 19/11/05

How do I get inserted row Id, along with related data back after insert without inserting the related data

*爱你&永不变心* 提交于 2020-03-02 07:55:12
问题 I have a set of data which need to result in a new row in a table. Once this row is created I need to attach metadata in separate tables related to this information. That is I need to create my [Identity] first, get the GlobalId back from the row, and then attach [Accounts] and [Metadata] to it. Inserting data and getting the Id of the inserted row is easy enough (see query below). But I'm stumped as to how I get the personnumber , firstname , and lastname inserted into this temporary table

How do I get inserted row Id, along with related data back after insert without inserting the related data

故事扮演 提交于 2020-03-02 07:54:02
问题 I have a set of data which need to result in a new row in a table. Once this row is created I need to attach metadata in separate tables related to this information. That is I need to create my [Identity] first, get the GlobalId back from the row, and then attach [Accounts] and [Metadata] to it. Inserting data and getting the Id of the inserted row is easy enough (see query below). But I'm stumped as to how I get the personnumber , firstname , and lastname inserted into this temporary table