sql-server-2016

Multiple SELECT statements into a single JSON

亡梦爱人 提交于 2020-06-23 04:43:37
问题 I'm convinced this must be answered somewhere but for the life of me I just can't seem to find anything no matter how much I change my search phrases. I need to select data from two completely independent tables and export the information to JSON. In this case, they're both 1 record in each table. If I select just 1 at a time and export to JSON, they're 1 record, but when I join the two single records in SQL and then export to JSON, they're 1 record arrays. Just 1 record SQL Input: DECLARE

COUNT number of times prior to specified time, self-join?

﹥>﹥吖頭↗ 提交于 2020-06-01 05:13:06
问题 For simplicity let's assume I have two tables: billing with the following fields bill_id (primary, unique key, int), person_id , bill_date , and billing_detail containing bill_id and service_type . First of all I would like a list of clients ( person_id ) who were billed for a given range of services in a given period, so simply SELECT billing.person_id, billing.bill_date FROM billing INNER JOIN billing_detail ON billing.bill_id = billing_detail.bill_id WHERE billing_detail.service_type IN

Read any JSON into list of key-value pairs (EAV format) in SQL Server

佐手、 提交于 2020-05-15 07:56:33
问题 Looking for a way to read any JSON without knowing the internals with SQL Server's JSON methods, I came up with an approach I'd like to share. Here is the question bringing up this issue. The question is: How can I transform an unknown JSON into a structured EAV format while keeping all the information about sort order and nest levels. The ideal output should carry the original row's id as the entity , the Json's key and value as the attribute and value together with the JsonPath for the

SSIS - the RPC server is unavailable

情到浓时终转凉″ 提交于 2020-05-15 02:56:46
问题 I've installed a instance of SQL Server and i select Integration Services in the setup wizard. However, when I run SQL Server Management Studio as 'Administrator', I can see my instance under. Database Engine Analysis Services Reporting Services However, I can't see my instance under 'Integration Services'. The service is running in Configuration Manager. UPDATE 1 When trying to enter the server name manually it gives the following error: the RPC server is unavailable 回答1: If you means this

How to remove Always Encrypted from a column in SQL Server 2016

╄→尐↘猪︶ㄣ 提交于 2020-05-14 19:12:54
问题 How can I remove the encryption property from a column in SQL Server 2016? I've enabled this feature using the Always Encrypted wizard in SQL Server Management Studio 2016, but I would like to remove the encryption from some columns I've added before. I wonder if the following 2 things are possible (and if so how?): Really undo the encryption using the certificate used for the encryption. Remove the encryption and leave the encrypted data in the cells. 回答1: The answer for question 1) is to

SSIS job fails when run remotely thru ssms, but runs fine on SQL Server

孤街浪徒 提交于 2020-05-13 18:05:19
问题 Installed SQL Server 2016 on a dev box, with SSIS. Have a package that loops thru a directory and validates XML files. The job runs fine on the SQL Server from the Integration Services Catalog and from SQL Server Agent, when executed there. Also runs fine in the local developers PC's. The issue comes in if you connect to the SQL Server via SSMS remotely, (Same user) and try to execute the package via Integration Services Catalog, it runs but fails to loop thru files. It gives the following

Iterate through columns and list all columns where a record has a value

元气小坏坏 提交于 2020-04-18 05:41:26
问题 I have the following table: ID Group Col1 Col2 Col3 Col4 ... ColN ------------------------------------------------------ 1 AAA foo bar 2 AAA 123 far baz 3 BBB 4 CCC 345 123 5 AAA caz For each Group , I need to find out in what Col umns it has a value. I do not care about the values themselves. Example: Group AAA has 3 ID s in it: 1, 2, 5 . ID 1 has a value in Col1, Col2 . ID 2 has a value in Col1, Col2 . ID 5 has a value in Col3 so in total, Group AAA has values in Col1, Col2, Col3 The output

Saving data in a SQL Server 2016 database for a specfic report

烈酒焚心 提交于 2020-02-07 03:50:06
问题 I was not sure how to title this but let me explain. I need to pull all of the publication article ID's from PubMed for every member of a Cancer Center. The ID's are normally 6 or 7 digest long. Currently I'm using a Stored Proc to save the id's in a comma separated string with the email address is the unique ID for the member. INSERT INTO [dbo].[ADMIN_Publications] ([Organization], [email], [PMID]) VALUES (@Organization, @Email, @PMID, ) The PMID's could be like 23579449,25465297,26512957

How to get column-level dependencies in a view

北城余情 提交于 2020-01-31 06:19:46
问题 I've made some research on the matter but don't have solution yet. What I want to get is column-level dependencies in a view. So, let's say we have a table like this create table TEST( first_name varchar(10), last_name varchar(10), street varchar(10), number int ) and a view like this: create view vTEST as select first_name + ' ' + last_name as [name], street + ' ' + cast(number as varchar(max)) as [address] from dbo.TEST What I'd like is to get result like this: column_name depends_on_column

How to get column-level dependencies in a view

不想你离开。 提交于 2020-01-31 06:18:53
问题 I've made some research on the matter but don't have solution yet. What I want to get is column-level dependencies in a view. So, let's say we have a table like this create table TEST( first_name varchar(10), last_name varchar(10), street varchar(10), number int ) and a view like this: create view vTEST as select first_name + ' ' + last_name as [name], street + ' ' + cast(number as varchar(max)) as [address] from dbo.TEST What I'd like is to get result like this: column_name depends_on_column