sql-server-2012

Update XML stored in a XML column in SQL Server

自古美人都是妖i 提交于 2019-12-04 01:07:33
问题 I have a sample table in SQL Server 2012. I am running some queries against but the .modify() XQuery method is executing but not updating. Here is the table For this just trying to update settings to 'NewTest' This will execute but nothing is updating! Thanks for any help! 回答1: Since there is a XML namespace ( xmlns:dev="http://www.w3.org/2001/XMLSchema" ) in your XML document, you must inlcude that in your UPDATE statement! Try this: ;WITH XMLNAMESPACES(DEFAULT 'http://www.w3.org/2001

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

岁酱吖の 提交于 2019-12-03 23:58:17
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 looking at enhancing my table by possibly changing the value column to a sql_variant datatype, but I don't

SQL Server xp_delete_file parameters

半腔热情 提交于 2019-12-03 23:54:21
Who can explain list of xp_Delete_file parameters in sql server. I don't find msdn document for this stored procedure. I got script of xp_Delete_file from maintenance plan but didn't understand first parameter. Xp_delete_file take five parameters: File Type = 0 for backup files or 1 for report files. Folder Path = The folder to delete files. The path must end with a backslash "\". File Extension = This could be 'BAK' or 'TRN' or whatever you normally use. Date = The cutoff date for what files need to be deleted. Subfolder = 0 to ignore subfolders, 1 to delete files in subfolders. Source How to

Sum values from multiple rows into one row

梦想与她 提交于 2019-12-03 23:51:33
问题 In SQL Server 2012, I have a table my_table that has columns state, month, ID , and sales . My goal is to merge different rows that have the same state, month, ID into one row while summing the sales column of these selected rows into the merged row. For example: state month ID sales ------------------------------- FL June 0001 12,000 FL June 0001 6,000 FL June 0001 3,000 FL July 0001 6,000 FL July 0001 4,000 TX January 0050 1,000 MI April 0032 5,000 MI April 0032 8,000 CA April 0032 2,000

Passing parameter of type 'object' in table-valued parameter for sql_variant column

吃可爱长大的小学妹 提交于 2019-12-03 23:43:30
问题 I have a table-valued parameter in SQL Server 2012 defined as: CREATE TYPE [dbo].[TVP] AS TABLE ( [Id] [int] NOT NULL, [FieldName] [nvarchar](100) NOT NULL, [Value] [sql_variant] NOT NULL ) I call it in C# with code that looks roughly like the following: var mdItems = new DataTable(); mdItems.Columns.Add("Id", typeof(int)); mdItems.Columns.Add("FieldName", typeof(string)); mdItems.Columns.Add("Value", typeof(object)); mdItems.Rows.Add(new object[] {2, "blah", "value"}); //'value' is usually a

Is there an overview of all SQL Server 2012 error codes?

对着背影说爱祢 提交于 2019-12-03 22:56:28
SQLGetDiagRec returns a native error code. Is there anywhere an overview of the error codes of SQL Server 2012? I couldn't find anything on MSDN. I'm unable to find a list of the individual codes in the internet. However I did find a list of the severity levels here on MSDN. They are as follows: Severity level / Description 0-9: Informational messages that return status information or report errors that are not severe. The Database Engine does not raise system errors with severities of 0 through 9. 10: Informational messages that return status information or report errors that are not severe.

Connect Matlab to Sql server

心不动则不痛 提交于 2019-12-03 22:21:26
I want to connect Matlab to Sql server . this is my code: db = database('ChifcoProd-2013-12-12-11-37', '', '', 'sqljdbc4.jar',... 'jdbc:microsoft:sqlserver://localhost:1433;database=ChifcoProd-2013-12-12-11-37') error: JDBC Driver Error: sqljdbc4.jar. Driver Not Found/Loaded the driver is already installed and I added the path to javaclasspath but it doesn't work. Try using the Help within MatLab, its very helpful. You are using the correct database connection: conn = database(instance,username,password,driver,databaseurl) The example provided by MatLab looks like this: Connect to an Oracle

How can I restore a database backup file (.bak) from SQL Server 2012 into SQL Server 2008 Express?

隐身守侯 提交于 2019-12-03 22:17:48
A database that was originally from SQL Server 2008, was restored into SQL Server 2012. A backup from SQL Server 2012 was made and I am trying to restore it on my local SQL Server 2008 Express. However I get an error 'Specified cast is not valid' (SQLManagerUI). I have generated an SQL Script from 2012 and set it so that it will generate with compatibility to SQL Server 2008. However it is a large sql file, around 700mb. I recall before that I had tried to run a script of that size before on my local SQLExpress and also got an error. Is there a way I can get a "large" database from SQL Server

Tally Table to insert missing dates between two dates? SQL

偶尔善良 提交于 2019-12-03 22:16:15
问题 I pieced together the below code from research from the net and my own SQL knowledge (not the greatest). The table Table_One holds data for staff and their working days, what I am trying to do is INSERT rows where the dates are missing (non-working days) between two specified dates for each Staff member. This is as far as I can get, I don't know how to check if the row is missing and if it is, insert the new row with the date and the corresponding staff members data. SET NOCOUNT ON; IF object

DbGeography make circle with center and radius

不羁岁月 提交于 2019-12-03 20:34:49
I create a DbGeography-point like this: String selectedLocation = String.Format("POINT ({0} {1})", lon, lat).Replace(",", "."); DbGeography selectedLocationGeo = DbGeography.FromText(selectedLocation, 4326); I also have a radius R. I want to create a curvepolygon with the shape of a circle with the specified radius from the point-coordinate. Be aware that I am using DbGeography, and not DbGeometry. How do I create the CIRCULARSTRING? Or is there a better way than using a CIRCULARSTRING? Something like this perhaps? String polyString = String.Format("CURVEPOLYGON(CIRCULARSTRING(xx yy, xx yy, xx