sql-server-2016

How to get column-level dependencies in a view

久未见 提交于 2020-01-31 06:18:26
问题 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

Copy database from SQL server management to another instance Directely

ぃ、小莉子 提交于 2020-01-24 23:12:06
问题 There are many ways to transfer databases from server to another. Some wizard and other programmatic as SMO That have Backup And Restore Classes That can help to take backup from server and restore to destination. If there are way to copy database directly without backup and restore Programmatic ? Where I determine the source that need to take copy of database and Destination that need to send database to it . (I know the wizard way of sql server But i need it programmatic ). please help .

Copy database from SQL server management to another instance Directely

时光怂恿深爱的人放手 提交于 2020-01-24 23:11:21
问题 There are many ways to transfer databases from server to another. Some wizard and other programmatic as SMO That have Backup And Restore Classes That can help to take backup from server and restore to destination. If there are way to copy database directly without backup and restore Programmatic ? Where I determine the source that need to take copy of database and Destination that need to send database to it . (I know the wizard way of sql server But i need it programmatic ). please help .

SQL Server 2016 _can't start mirror

折月煮酒 提交于 2020-01-24 12:48:26
问题 After upgrading SQL Server 2014 to SQL Server 2016 (both Enterprise editions), I can't start mirror. This works normally on SQL Server 2014. After I restore (WITH NORECOVERY) mirror database with full and log backups of primary database I normally run configure setup . After click on Start mirror I get this error: Database 'DatabaseName' cannot be open. It is in the middle of a restore. (Microsoft SQL Server, Error:927) 回答1: Issue with SQL 2016 GUI. Its worked with TSQL commands. Mirror

Empty string results in “Errors were detected in the command line arguments, please make sure all arguments are set correctly”

99封情书 提交于 2020-01-24 04:28:46
问题 On a SQL 2016 Server I have a job that calls an SSIS package. That package is in a project in the SSISDB and has parameters. One of those parameters is a string type that is blank as a default. I ran the job with the blank value for this parameter, and it ran successfully. I then opened the job properties, went to the step that calls that package and went into the configuration and gave that parameter a value. I ran the job again and it ran successfully, and the parameter value had the

SSRS Error - "Report item expressions can only refer to fields within the current dataset scope or, if inside an aggregate

最后都变了- 提交于 2020-01-15 10:33:58
问题 I'm new to SSRS and I'm not sure if it will do what I would like to do. I'm getting the following error in SSRS: "The Value expression for the text box 'Textbox17' refers to the field 'DayCnt'. Report item expressions can only refer to fields withing the current dataset scope or, if inside an aggregate, the specified dataset scope. Letters in the names of fields must use the correct case." I have a list that's 3 rows and 3 columns. I need to use multiple data sets across the rows and columns.

SQL Server: adding foreign key on multiple columns

不想你离开。 提交于 2020-01-14 22:39:37
问题 I'm trying to create a foreign key on two columns of a table to point to the same column of another table, but I seem to get an error. I'm using SQL Server with Microsoft SQL Server Management Studio. Here's what I do: CREATE TABLE House ( hid INTEGER PRIMARY KEY, hname VARCHAR(32) NOT NULL, address VARCHAR(128) NOT NULL, ); CREATE TABLE Room ( sid INTEGER, hid INTEGER FOREIGN KEY REFERENCES House(hid), rname VARCHAR(32) NOT NULL, CONSTRAINT sid_pk PRIMARY KEY(sid, hid) ); CREATE TABLE Seat (

SQL Server: adding foreign key on multiple columns

半城伤御伤魂 提交于 2020-01-14 22:36:57
问题 I'm trying to create a foreign key on two columns of a table to point to the same column of another table, but I seem to get an error. I'm using SQL Server with Microsoft SQL Server Management Studio. Here's what I do: CREATE TABLE House ( hid INTEGER PRIMARY KEY, hname VARCHAR(32) NOT NULL, address VARCHAR(128) NOT NULL, ); CREATE TABLE Room ( sid INTEGER, hid INTEGER FOREIGN KEY REFERENCES House(hid), rname VARCHAR(32) NOT NULL, CONSTRAINT sid_pk PRIMARY KEY(sid, hid) ); CREATE TABLE Seat (

SQL 2016 - Converting XML to Json

*爱你&永不变心* 提交于 2020-01-14 14:01:27
问题 I'm trying to convert a XML column to Json using FOR JSON PATH in SQL2016 but I'm having some issues. Given the following XML (note that some Product elements might have a list of Product inside): <Request> <SelectedProducts> <Product id="D04C01S01" level="1" /> <Product id="158796" level="1" /> <Product id="7464" level="2"> <Product id="115561" level="3" /> </Product> <Product id="907" level="2"> <Product id="12166" level="3" /> <Product id="33093" level="3" /> <Product id="33094" level="3"

Why SQL returns an Array instead of an Object?

青春壹個敷衍的年華 提交于 2020-01-14 08:46:07
问题 I'm using SQL SERVER 2016 JSON result, but I don't know why it converts everything to array, e.g. if I execute the following query it returns an array instead of an object: SELECT 1 AS One,2 AS Two,3 AS Three FOR JSON PATH The result is: [{"One":1,"Two":2,"Three":3}] But I would like it to return: {"One":1,"Two":2,"Three":3} Also I tested this query, but the result was the same, again an array: SELECT TOP 1 1 AS One,2 AS Two,3 AS Three FOR JSON PATH 回答1: You just need the WITHOUT_ARRAY