sql-server-2012

Entity Framework 5.0 and FileTable

一曲冷凌霜 提交于 2019-12-06 13:16:16
So say I have the following tables in my SQL Server 2012 DB: Person PersonId FirstName LastName Photo PhotoId PersonId (fk) DateTaken PhotoFileTable (all the FileTable columns) And the photos stored on disk are structured like this: \\myserver\filestreamshare\People\PersonId\Photo1.tif And very important: There are a TON of photos ALREADY on disk that need to be added to the database- that's why I thought a FileTable would be cool as it automatically picks them up. So I need to do 2 things- first, relate the Photo table to the PhotoFileTable so that I can get all photos for a person. And

OPENDATASOURCE instead of Linked Server

江枫思渺然 提交于 2019-12-06 11:29:05
I have a situation where a linked server to an access DB is crashing my SQL server. Crashed here means adding the linked server causes all other linked servers using that provider to stop working. Any queries to those linked servers hang and don't complete. This situation persists until the server is restarted. However, when I use OPENDATASOURCE to connect to the same data source I don't have this problem. Why would one work and the other crash? The provider I'm using is Microsoft.ACE.OLEDB.12.0. I have Dynamic parameter and Allow inprocess enabled. Example query below select * from

Cannot register stdole assembly in SQL Server 2012

删除回忆录丶 提交于 2019-12-06 10:51:13
I am in the process of migrating a SQL Server 2008 to 2012 and running into challenges in creating some of the necessary assemblies for a CLR routine. The routine takes a dependency on stdole.dll , but I am unable to create this assembly. My code is as follows: ALTER DATABASE main SET TRUSTWORTHY ON; create assembly [stdole] from 'C:\Program Files (x86)\Microsoft.NET\Primary Interop Assemblies\stdole.dll' WITH PERMISSION_SET = unsafe I am receiving the following error: Warning: The Microsoft .NET Framework assembly 'stdole, version=7.0.3300.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a.'

Query XML creating field names whithout knowing node names

寵の児 提交于 2019-12-06 10:29:17
问题 If I have a SQL SERVER 2012 table containing an XML field type. The records it could contain are as follows. I have simplified my problem to the following. Record 1: ID_FIELD='nn1' XML_FIELD= <KNOWN_NAME_1> <UNKNOWN_NAME1>Some value</UNKNOWN_NAME1> <UNKNOWN_NAME2>Some value</UNKNOWN_NAME2> ... Maybe more ... </KNOWN_NAME_1> Record 2: ID_FIELD='nn2' XML_FIELD= <KNOWN_NAME_2> <UNKNOWN_NAME1>Some value</UNKNOWN_NAME1> <UNKNOWN_NAME2>Some value</UNKNOWN_NAME2> ... Maybe more unknown fields ... <

C# & SQL Server - best way to delete multiple Rows in “one go” using a stored procedure

拟墨画扇 提交于 2019-12-06 09:02:12
问题 I know there's many of the same subjected question here in SO, my question is if I want to delete say around 1K rows rather few, given a List<int> of RecordID , I could avoid using a DataTable , and send the list translated into a statement: string ParmRecordsToDelete_CsvWhereIN = "(" for(int CurIdx=0; CurIdx < RecIdsToDelete.Count; CurIdx++) { ParmRecordsToDelete_CsvWhereIN += RecIdsToDelete[CurIdx] + ", "; //this method to create passed parameter //logic to remove on last Coma on last Index

SQL Server 2012 not showing unicode character in results

佐手、 提交于 2019-12-06 08:46:20
问题 All I want to do is update a field with the DIRECT CURRENT SYMBOL FORM TWO ⎓ character into my SQL Server 2012 database. Is that too much to ask? Apparently it is. The answer to this question and this question is the same and did not work for me. My update script UPDATE Table SET Value = N'SUPPLY 9-30Vdc 0.2W ⎓' WHERE id = '1234' Aaaaand the relevant table schema: CREATE TABLE [dbo].[Table] ( ... ... [Value] [nvarchar] (1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, ... ... ) ON

How scale is defined when decimal and bigint are divided?

百般思念 提交于 2019-12-06 07:53:07
I have value A of type DECIMAL(19,8) - the scale is 8 , so the number of decimal digits that will be stored to the right of the decimal point is 8 . Now, I am dividing A on B , where B is BIGINT . For, example: SELECT CAST(3 AS DECIMAL(19, 8)) / CAST(27 AS BIGINT) -- 0.111111111111111111111111111 ,CAST(300 AS DECIMAL(19, 8)) / CAST(27 AS BIGINT) -- 11.111111111111111111111111111 ,CAST(75003 AS DECIMAL(19, 8)) / CAST(13664400 AS BIGINT) -- 0.005488934750153684025643277 the output values are with length: 29 , 30 , 29 respectively. Could anyone tell why the length of the value for the three

How to find rows by filtering a specific text using Full text search in MS SQL 2012

放肆的年华 提交于 2019-12-06 07:34:16
I have a requirements to find rows by filtering a specific text using Full Text Search in MS SQL. The first requirement is to find rows by searching the text within the xml column, and the second requirement, is to find rows by searching the text within the json column(nvarchar data type). The following conditions should return a result. XML Column Criteria 1. Where Contains(XMLData,"1") Criteria 2. Where Contains(XMLData,"/1/") Criteria 3. Where Contains(XMLData,"<field>1</field>") JSONDATA Column : Criteria 1. Where Contains(JSONData,"1") Criteria 2. Where Contains(JSONData,"/1/") Criteria 2

Logging update operation in triggers

旧城冷巷雨未停 提交于 2019-12-06 07:22:27
I have an UPDATE trigger that produces INSERTED and DELETED table like this: INSERTED Id Name Surname 1 Stack Overflow 2 Luigi Saggese DELETED Id Name Surname 1 Stacks Overflow 2 Luigi Sag I want to capture this update to a log table. My Log table (that is global for all tables) is like this (then I must process my INSERTED and DELETED table): Id_Table Table_Key_Value Id_Value Old_Value New_Value 12345 1 4556645 Stack Stacks 12345 1 544589 Overflow Overflows 12345 2 544589 Saggese Sag Id_Table is the table's system object_id where I have performed the UPDATE statement, Table_Key_Value is the

Create Geometry/Geography Field from Latitude & Longitude fields (SQL Server)

丶灬走出姿态 提交于 2019-12-06 07:21:28
I have a view that contains two fields for latitude and longitude, and I would like to create a new view that converts these lat/lon fields into a geometry/geography field (unsure which is most appropriate for ArcGIS). The fields in the original view are of double type, and I would like them cast as a spatial type in my new view. Currently I am unsure how to cast these fields as spatial types. All the other similar questions on Stack Overflow never got me a working solution, so I apologize if this question appears to be a duplicate, but hopefully a clearer example could help others as well. My