sql-server-2012

Are there any benefits to using sql_variant over varchar in SQL Server?

浪子不回头ぞ 提交于 2019-12-05 12:49:06
问题 I currently have a database table setup as follows (EAV - business reasons are valid): Id - int (PK) Key - unique, varchar(15) Value - varchar(1000) This allows me to add in mixed values into my databse as key/value pairs. For example: 1 | 'Some Text' | 'Hello World' 2 | 'Some Number' | '123456' etc. In my C# code I use ADO.Net using reader.GetString(2); to retrieve the value as a string, then have my code elsewhere convert it as needed, for example... Int32.ParseInt(myObj.Value); . I'm

Recursive CTE to find all ancestors OF ALL ITEMS

﹥>﹥吖頭↗ 提交于 2019-12-05 12:40:51
I have a simple hierarchy and need to be able to generate a single table that matches EACH item in the table with ALL of its ancestors. (Caps to emphasize that this is not a duplicate question!) So here's a table: Select Item='A', Parent=null into Items union Select Item='B', Parent='A' union Select Item='C', Parent='A' union Select Item='D', Parent='B' union Select Item='E', Parent='B' union Select Item='F', Parent='C' union Select Item='G', Parent='C' union Select Item='H', Parent='D' Go ... which represents this hierarchy: A / \ B C / \ / \ D E F G / H So B has one ancestor (A), and H has 3

Proper / title case in t-sql

时光总嘲笑我的痴心妄想 提交于 2019-12-05 11:46:50
I'm using SQL 2012 RC0, and looking for a function that can convert a column that holds first and last names into proper/title case. I've had a look around SO but can't seem to find anything, if there is another post please let me know and I will close this one. The table column I want to convert is filled from a user entered field from a web front-end, so at times is not entered in a format that can be used for the purpose of populating name fields on reports for customers (appreciate validation at the front-end can be made stricter, however this doesn't solve the problem of the customers

Constant SQL Server 80% CPU Utilization

≯℡__Kan透↙ 提交于 2019-12-05 11:24:16
We have a small (for now) Asp.Net MVC 5 website on a dedicated VPS. When I go to the server and fire-up task manager, I see that "SQL Server Windows NT - 64 bit" is using around 80% of CPU and 170MB of RAM and IIS is using 6% CPU and 400MB of RAM. Server Specs are: CPU 1.90Ghz dual core Memory 2GB Windows Server 2012 SQL Server Express 2012 Disk Space: 25GB, 2.35 Free. The database is not very big. Its backup is less than 10MB. I have tried to optimize the website as much as I could. I added caching to a lot of controllers and implemented donut caching for quite a lot of controllers. But today

msxml3.dll in context sp_OAMethod 'send'

匆匆过客 提交于 2019-12-05 11:14:16
Working code from Win2003 + SQL Server 2005 is not working under Win2012 + SQL Server 2012 sp1. The only ~real solution I found is: I copied C:\Windows\System32\msxml3.dll from a Server 2008 to the same dir on a server 2012. Problem on 2012 server solved, sending with POST and GET working fine. But as I cannot modify server and both msxml3.dll and msxml6.dll are locked - I need to understand what is wrong and apply other way. Code is simple as usual for grabbing soap web service: Declare @Object as Int; Declare @ResponseText as Varchar(8000); Declare @ErrCode Int; Exec sp_OACreate 'MSXML2

SSRS 2012 Custom Code .NET Framework 4.0 not supported

冷暖自知 提交于 2019-12-05 11:06:10
问题 I was very hopeful that since SQL Server 2012 SQLCLR supports .NET 4.0 that SQL Server Reporting Services (SSRS) 2012 would support .NET 4.0 custom code assemblies. When attempting to upload an rdl (via the Report Manager or via RSBuild) that references .NET 4.0 assemblies, the Reports Manager throws an error stating This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded. (rsErrorLoadingCodeModule) Is there something I can configure to get SSRS 2012

what would cause a linked server to return a limited amount of data?

守給你的承諾、 提交于 2019-12-05 10:39:29
We are having an issue with a server that we linked to our sql server 2012 instance. The server that we linked through an odbc or oledb connection is Pervasive SQL. Selecting from the linked server this way works as long as the result set is small: select * from linked_server.database..mytable If the result set is more than around 2mb (might be slightly more or less) then we get this error: Msg 7399, Level 16, State 1, Line 1 The OLE DB provider "MSDASQL" for linked server "KSLAP208" reported an error. The provider reported an unexpected catastrophic failure. Msg 7330, Level 16, State 2, Line

Conversion failed when converting from a character string to uniqueidentifier - Two GUIDs

两盒软妹~` 提交于 2019-12-05 09:07:00
问题 I don't understand why I can't insert this. I can't spot the problem. The error message is Conversion failed when converting from a character string to uniqueidentifier. The GUIDs are the ones that I got when I did a select from some other tables. insert into [db].[dbo].[table] (myid,friendid,time1,time2) values ( CONVERT(uniqueidentifier,'0C6A36BA-10E4-438F-BA86-0D5B68A2BB15'), CONVERT(uniqueidentifier,'DF215E10-8BD4-4401-B2DC-99BB03135F2E'), '2014-01-05 02:04:41.953','2014-01-05 12:04:41

Create evenly sized groups based on aggregate

回眸只為那壹抹淺笑 提交于 2019-12-05 08:10:33
Probably a newbie question, but I'm looking to split our server inventory up into several evenly sized groups based on total database size, and am stumped figuring out how to group them. I think NTILE will work, maybe, but I just can't wrap my head around splitting the groups evenly. My example below is just ordering the servers randomly. I would like the results to be 3 groups of fairly even size (obviously won't be exact). Using SQL Server 2012. Any help is appreciated. Thanks. declare @Servers table (ServerName sysname, TotalSizeGB decimal (12,2)) insert into @Servers values ('Server1',123

Why can't I connect to my mssql database using PHP?

情到浓时终转凉″ 提交于 2019-12-05 08:04:56
I've done so much research trying to get my PHP code hosted on IIS to connect to my MSSQL database. I just can't seem to figure out the issue. Has anyone come across this before? <?php $serverName = 'AEGIS-PC\SQLEXPRESS'; $connectionInfo=array('Database'=>'tttb_db'); $con = sqlsrv_connect($serverName, $connectionInfo); if($con){ echo 'Connection established<br />'; } else { echo 'Connection failed<br />'; die(print_r(sqlsrv_errors(), TRUE)); } ?> Update, we have a new error: Connection failed Array ( [0] => Array ( [0] => 28000 [SQLSTATE] => 28000 [1] => 18456 [code] => 18456 [2] => [Microsoft