sql-server-2012

Is Schema in Oracle is equivalent to Database in Microsoft SQL Server?

偶尔善良 提交于 2019-12-25 04:15:42
问题 I am new to Oracle database and I wanted to create a database in Oracle. I followed this link to create a database: http://www.fehily.com/books/createdb/createdb_oracle_11g_2.html In Microsoft SQL Server, when we create a database, we use the create database command and the database creation is instantaneous [within fraction of seconds], but the Database Tool as described in link above took couple of minutes to create the database. Is database creation in Oracle this much slower? Searching

concatenate values of one column to single text

北城余情 提交于 2019-12-25 04:15:26
问题 my Column is like this: col1 Mary Jack John and i need to get something like this: Mary,Jack,John I did it by using "For XML PATH", but the problem is that segment not work in SQL server view, is there other way to get concatenation of one column? 回答1: try using SQL COALESCE experession to convert your column values into a comma separated string. here's what you need to do. DECLARE @test TABLE ( SampleCol varchar(50) ) INSERT INTO @Test VALUES ('Test') INSERT INTO @Test VALUES ('Test 1')

Case Statement Logic Not Fully Functional

这一生的挚爱 提交于 2019-12-25 04:07:08
问题 Below are some example results that I am expecting from my script: Example 1: Customer 12 was provided only service 'NEI2'. then result should be AcctNum PStatus IStatus 12 1 5 Example 2: If customer 21 had service 'PN20', 'PN4', and 'FL1' then the result should be AcctNum PStatus IStatus 21 3 2 21 4 5 Response will always be 'Y'. You can modify the script if you need to. Thank you. Below is the script: SELECT distinct A.AcctNum, CASE WHEN O.Order = 'NEI2' THEN '1' WHEN AV.Query IN ('PNE1',

stuff() adds separator even when fields are empty

☆樱花仙子☆ 提交于 2019-12-25 03:49:59
问题 Please consider the following statement: select stuff(( select '; ' + ([FIELD_1] + [FIELD_2] + [...] + [FIELD_N]) from [TABLE] t1 where t1.[ID] = t2.[ID] for xml path ('') ),1,1, '') from [TABLE] t2 If the statement concatenates 10 records with the same ID but all records have no value ('', or empty, instead of null ), the output is: ; ; ; ; ; ; ; ; ; ; If 2 records are filled, I end up with ; ; ; AAA; ; ; ; BBB; What I would want in these 2 cases is null , respectively AAA; BBB I tried

Stored Procedure Insert multiple rows

时光怂恿深爱的人放手 提交于 2019-12-25 03:28:29
问题 I have a table, FruitCrateID FruitID Now FruitID and FruitCrateID have a many-to-many relationship. I have a strongly typed dataset I need to create add and update stored procedure. Now I can use foreach to add FruitID and FruitCrateID to database but there will be several calls for example, FruitCrateID - 124 FruitID - 23 FruitID - 245 FruitID - 242 and so on .... What I created so far.. I want to add them all in a single query.. IF (EXISTS (SELECT * FROM FruitShoppingList WHERE FruitCrateID

An error occurred during Service Master Key decryption

走远了吗. 提交于 2019-12-25 03:18:13
问题 I am relatively new to SQL so will try explain as best I can. All servers are SQL Server 2012 I currently have a database which has two Linked Servers to access two other databases. From these 3 databases I have setup 5 view which are referenced in a stored procedure. When trying to run the stored procedure it was failing, I opened the procedure and tried to run it manually to see what the issue was and received the below error: Msg 33094, Level 16, State 1, Line 16 An error occurred during

Summing common columns of multi table parent-child relation

纵饮孤独 提交于 2019-12-25 02:53:16
问题 I have four tables which are structured in a parent-child relation. One table has a primary key and the other three tables, otherwise unrelated to each other, have that primary key as a foreign key. That is, Table A has a primary key called customer ID. Tables B, C, and D also have customer ID and some other information. What I want to achieve is to sum column2 of tables B, C, and D. I have tried: SELECT dbo.a.primary_key, SUM(dbo.b.column2) AS Expr1, SUM(dbo.c.column2) AS Expr2, SUM(dbo.d

select statement working unexpectedly

大兔子大兔子 提交于 2019-12-25 02:43:23
问题 when i click SELECT TOP 1000 row from table then it only shows some records like 3 records but when i manually run query on same table then it shows all records like many 1000s records which i always want. Select * from dbo.HrEmployee why ? Help please, i'm using SQL SERVER 2012 回答1: It look like you have created two copies of the same database, the one is in the “intended” database and the second has been created in the master database. 3 records were then inserted into the intended table

How to split comma separated values stored in XML node Without using function- SQL Server 2012

久未见 提交于 2019-12-25 01:06:44
问题 I have a requirement to split a csv data inside a xml node column. I am using SQL server 2012. I want a query without creating a function. The data is as follows for example ID : 1 XMLvalue : <BETA> <SERIAL NAME="ASSESSMENT"> ASSESSMENT=1,ASSESSMENT=2,ASSESSMENT=3</SERIAL> <SERIAL NAME="PROJECT"> PROJECT=1,PROJECT=2,PROJECT=3</SERIAL> </BETA> ID : 2 XMLvalue : <BETA> <SERIAL NAME="ASSESSMENT"> ASSESSMENT=4,ASSESSMENT=5,ASSESSMENT=6</SERIAL> <SERIAL NAME="PROJECT"> PROJECT=4,PROJECT=5,PROJECT

mssql php can't select field type nvarchar(MAX)

北城余情 提交于 2019-12-25 00:41:36
问题 I use this code to select password field from the sql server 2012 db, and does not return any data I tried to change the field type and it did work actually I can't change the field type in the main server and I need to work with it as it is any idea how to work around it? <?php $objConnect = mssql_connect("localhost:1434\MSSQLSERVER","fdi","fdifdi"); if($objConnect) { echo "Database Connected.<br />"; mssql_select_db('Intranett', $objConnect); $query = mssql_query('SELECT [pass] FROM