sql-server-2012

compare s, t with ş, ţ in SQL Server

房东的猫 提交于 2019-12-07 14:47:48
问题 I followed this post How do I perform an accent insensitive compare (e with è, é, ê and ë) in SQL Server? but it doesn't help me with " ş ", " ţ " characters. This doesn't return anything if the city name is " iaşi " : SELECT * FROM City WHERE Name COLLATE Latin1_general_CI_AI LIKE '%iasi%' COLLATE Latin1_general_CI_AI This also doesn't return anything if the city name is " iaşi " (notice the foreign ş in the LIKE pattern): SELECT * FROM City WHERE Name COLLATE Latin1_general_CI_AI LIKE '

Mainting Identity value across multiple tables

别说谁变了你拦得住时间么 提交于 2019-12-07 13:27:15
问题 We have a situation where we have a column called Customer_Number in multiple tables. This column is identity column in all the tables, but is there a way that I can make this column unique among all the tables. for example if I add a row in table_one and identity column assigns it value 1 now if someone add another row in Customer_Number column of table_two , table_three or table_four it should be assigned 2. how can I do this, I have been reading online and it seems I have to create a table

Is Changing IF EXIST(SELECT 1 FROM ) to IF EXIST(SELECT TOP 1 FROM ) has any side effects?

独自空忆成欢 提交于 2019-12-07 13:21:21
问题 I have an existing SP running on my production server. I have found some significant performance gain from changing IF EXIST(SELECT 1 FROM ) to IF EXIST(SELECT TOP 1 1 FROM ) and IF NOT EXIST(SELECT 1 FROM ) to IF NOT EXIST(SELECT TOP 1 1 FROM ) . The only difference is TOP 1 keyword. Just curious to know whether changing this has any side effect? 回答1: No, there should be no difference. EXISTS bails out as soon as it has found a single matching row. That's why it's always preferred over e.g.

Deadlock on 2 pages

和自甴很熟 提交于 2019-12-07 12:56:18
问题 I'm troubleshooting some deadlocks I'm seeing in a production environment and I'm new to this but something seemed odd to me. So I have the deadlock graph below: The right side of the deadlock is an update that is the following: UPDATE order_sub_line SET sub_line_status = 300 WHERE order_sub_line_id = '75C387EC-A1A7-4587-9FA0-DD33A49009BC' It looks to me in the graph that this update is trying to acquire 2 page locks. order_sub_line_id is a clustered index. Should this be trying to acquire 2

Retrieve UDT table structure in VB.NET

跟風遠走 提交于 2019-12-07 12:47:59
问题 In searching for my answer, I saw this question: ADO.NET Retrieve UDT Columns from SQL Server 2012? but it remains unanswered. In short, this is my question, but the context is below. I have a SQL Server 2012 stored procedure that takes two table-valued parameters (TVPs) which I want to call from VB.NET (3.5 now, but I am not married to this). I have used SqlCommandBuilder.DeriveParameters to determine the parameters of my stored procedure: cmd1 = New SqlCommand() cmd1.Connection = oCn2 '

“Streaming” read of over 10 million rows from a table in SQL Server

跟風遠走 提交于 2019-12-07 12:22:52
问题 What is the best strategy to read millions of records from a table (in SQL Server 2012, BI instance), in a streaming fashion (like SQL Server Management Studio does)? I need to cache these records locally (C# console application) for further processing. Update - Sample code that works with SqlDataReader using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Data; using System.Data.SqlClient; using System.Threading;

Using SQL Server 2012 LAG

那年仲夏 提交于 2019-12-07 11:56:54
问题 I am trying to write a query using SQL Server 2012 LAG function to retrieve data from my [Order] table where the datetime difference between a row and the previous row is less than equal to 2 minutes. The result I'm expecting is 1234 April, 28 2012 09:00:00 1234 April, 28 2012 09:01:00 1234 April, 28 2012 09:03:00 5678 April, 28 2012 09:40:00 5678 April, 28 2012 09:42:00 5678 April, 28 2012 09:44:00 but I'm seeing 1234 April, 28 2012 09:00:00 1234 April, 28 2012 09:01:00 1234 April, 28 2012

Combine multiple rows into one row

老子叫甜甜 提交于 2019-12-07 10:06:03
问题 I'm trying different JOIN queries, but I'm not getting result I'm looking for. I've got 2 tables: Table 1: **StockItemShort** ItemID | Code | Name 432724 | CK002-16-09 | Green Daisy Pearl Earrings 432759 | CK002-16-149 | Emerald Crystal Centre Daisy Earrings Table 2: **StockItemCatSearchValueShort** ItemID | SearchValueID 432724 | 388839 432724 | 389061 432724 | 390269 432724 | 389214 432759 | 388839 432759 | 389051 432759 | 390269 432759 | 389214 I can't get result I'm looking for. I'd like

Making sense of 'OFFSET/FETCH' in SSMS 2012

ぐ巨炮叔叔 提交于 2019-12-07 09:52:29
Just installed Microsoft SQL Server Management Studio 2012 today. In familiarizing myself with the pagination feature addition of ORDER BY, I keep running into this error: Msg 102, Level 15, State 1, Line 5 Incorrect syntax near 'OFFSET'. Msg 153, Level 15, State 2, Line 6 Invalid usage of the option NEXT in the FETCH statement. Here is my query: SELECT SingleWomansName, NumberOfCats FROM CatLadies WHERE NumberOfCats > 1 ORDER BY NumberOfCats OFFSET 10 ROWS FETCH NEXT 5 ROWS ONLY I've seen plenty of how-to articles with similar syntax. What gives? http://msdn.microsoft.com/en-us/library

Issue connecting Oracle 11g to SQL Server 2012 — ORA-12523: TNS:listener could not find instance appropriate for the client connection

末鹿安然 提交于 2019-12-07 09:19:25
I have Oracle 11g and SQL Server 2012 installed on the same virtual machine. OS is Windows Server 2012. I want to access SQL Server 2012 from Oracle. I created the machine a few days back to test the connection process before applying it on server. I had come through several issues but now I am stuck with this one. ORA-12523: TNS:listener could not find instance appropriate for the client connection I have already created ODBC Connection by the name of sqldb . kshaz is my machine name. Following are my configuration details. listener.ora file # listener.ora Network Configuration File: C:\app