sql-server-2012

Fetching complex objects by raw SQL query in Entity Framework

徘徊边缘 提交于 2019-12-05 07:32:31
I would like to fetch from database complex object using single query. Let's look at the following example: SELECT TableA.*, TableB.* FROM TableA INNER JOIN TableA.B_Id = TableB.Id and corresponding classes: public class QueryResult { public TableA A { get; set; } public TableB B { get; set; } } public class TableA { public int Id { get; set; } public string SomeContentA { get; set; } public int B_Id { get; set; } } public class TableB { public int Id { get; set; } public int SomeContentB { get; set; } } I would like to execute the raw SQL query from above against the database and get

SSIS Package Stuck at “Created Execution” Status

喜你入骨 提交于 2019-12-05 07:18:48
I recently deployed a update to one of my SSIS projects, and ever since the project has failed it's scheduled runs. The SSIS package appears to be stuck at the "Created Execution" status. There are no messages in the reports to explain this issue. I've attempted to redeploy the project, but the results remain the same. I ultimately had to revert to an earlier version of the deployment in order to bring the system back online, but I am now in a position where I can not update the project. I'm at a loss right now as to how to resolve this issue, and this project is a rather vital component to

Sql Developer connector to Sql Server 2012 - error “Vendor code 207”

╄→尐↘猪︶ㄣ 提交于 2019-12-05 07:02:53
I am trying to connect from Sql Develper 4.0.3.16 to Sql Server 2012, with jTDS connector jtds-1.3.1.jar. OS: Ubuntu 14.04 Java: ~$ java -version java version "1.7.0_72" Java(TM) SE Runtime Environment (build 1.7.0_72-b14) Java HotSpot(TM) 64-Bit Server VM (build 24.72-b04, mixed mode) In the create connection window, when I test the connection it is successful. When I open the connection I can see all the databases. When I try to open a database that I am supposed to have a permission to open, I am getting the following error window: Any ideas? P.S. if Microsoft has a JDBC driver sqljdbc4-4.0

How to solve Error 26: Error Locating Server/Instance Specified in production environment?

心不动则不痛 提交于 2019-12-05 06:56:38
I have a strange error in production environment BUT not in develop environment. In my develop environment, with Visual studio 2010, i can connect without problem to Sql Server 2012. When i copy my Windows Form app to others PC in the same network, i get an "Error 26:Error Locating Server/Instance Specified". The same application worked good with an old database instance with Sql Server 2008. I don't know what to check and where to start! EDIT: Another strange behavior is that it works good if i use a code like this conn.Open() dr = cmd.ExecuteReader() But stop to work if i open a form with a

How to create composite foreign key in sql server management studio 2012

☆樱花仙子☆ 提交于 2019-12-05 05:32:54
I can successfully create composite primary key in sql server management studio 2012 by selecting two columns (OrderId, CompanyId) and right click and set as primary key. But i don't know how to create foreign key on two columns(OrderId, CompanyId) in other table by using sql server management studio 2012. In Object Explorer, go to your table and select Keys > New Foreign Key from the context menu: From the dialog box that pops up, click on the Add button to create a new foreign key: Give it a meaningful name and then click on the ... button to open the Tables and Columns specification dialog

Count, order desc and select top 5

﹥>﹥吖頭↗ 提交于 2019-12-05 05:14:35
SQL Server 2012 We have a table, like such: ticket, type ------------------ 1234, hardware 1543, software 8859, network 5832, hardware 4900, hardware 8403, software 7859, network 4332, telephone 8721, database Our goal is to count up all tickets belonging to each type (so in this case the result should be 3 hardware, 2 software, 2 network, 1 telephone and 1 database ticket(s)), order them desc and select the first 5 resulting rows. We're trying to determine the top 5 "popular" or most seen ticket types (and how many there are). I've got the counting portion down but not sure how to proceed

Subtract hours from SQL Server 2012 query result

安稳与你 提交于 2019-12-05 05:12:04
I am running queries on an alarm system signal automation platform database in SQL Server 2012 Management Studio, and I am running into some hiccups. My queries run just fine, but I am unable to refine my results to the level that I would like. I am selecting some columns that are formatted as DATETIME , and I simply want to take the value in the column and subtract 4 hours from it (i.e., from GMT to EST) and then output that value into the query results. All of the documentation I can find regarding DATESUB() or similar commands are showing examples with a specific DATETIME in the syntax, and

SqlRoleProvider: NullReferenceException when calling Roles.GetRolesForUser

吃可爱长大的小学妹 提交于 2019-12-05 04:54:06
Scenario: WCF Service using SqlRoleProvider for authentication with a Sql Server 2012 Database server. WCF is hosted on a IIS7 webserver. please see this error: System.NullReferenceException: Object reference not set to an instance of an object. at System.Web.Security.Roles.GetRolesForUser(String username) RoleManagement is enabled. On my local development machine (server 2012, iis7) this works fine. When I log in and call the method the roles are retrieved. On the other server (test environment) it's not working. I can login (user is authenticated with user and pass against sql server

Stop SQL Server from running until needed [closed]

流过昼夜 提交于 2019-12-05 04:11:38
I have SQL Server 2012 installed on my PC, and usually don't need it. It's only for debugging purposes. I've seen it takes up quite some RAM so I'd like to prevent it from starting until I need it, start it, and then stop it when not needed again. How do I do that? (I have SSMS installed as well so I can use that if that's the way to do it.) To start, stop, pause, resume, or restart the an instance of the SQL Server Database Engine: On the Start menu, point to All Programs, point to Microsoft SQL Server 2012 , point to Configuration Tools, and then click SQL Server Configuration Manager. If

SQL Server: Lead/Lag analytic function across groups (and not within groups)

ぃ、小莉子 提交于 2019-12-05 03:53:51
Sorry for the long post, but I have provided copy & paste sample data and a possible solution approach below. The relevant part of the question is in the upper part of the post (above the horizontal rule). I have the following table Dt customer_id buy_time money_spent ------------------------------------------------- 2000-01-04 100 11:00:00.00 2 2000-01-05 100 16:00:00.00 1 2000-01-10 100 13:00:00.00 4 2000-01-10 100 14:00:00.00 3 2000-01-04 200 09:00:00.00 10 2000-01-06 200 10:00:00.00 11 2000-01-06 200 11:00:00.00 5 2000-01-10 200 08:00:00.00 20 and want a query to get this result set Dt Dt