sql-server-2012

Can't attach ASP.NET database to SQL Server Management Studio

此生再无相见时 提交于 2019-12-21 13:01:12
问题 I have an ASP.NET MVC3 project that has a database. I want to attach that database to SQL Server Management Studio. In SQL Server Management Studio, I right click Databases , then click Attach , then click Add and it shows the folder/file selection dialog. The problem is it won't let me explore any folder inside my user account folder ( c:\users\Bob ). I can see the Bob folder but there is no + to expand, and shows no child items (even though I know there are files in my windows user folder).

How to change SQL Server authorization mode without Management Studio

眉间皱痕 提交于 2019-12-21 12:37:33
问题 Is there a way to change the authorization mode in SQL Server 2008 or 2012 without using the SQL Server Management Studio? 回答1: Here is what Management Studio does to change the authentication mode from mixed to Windows only: EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'LoginMode', REG_DWORD, 1; And from Windows only back to mixed: EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'LoginMode',

Get family members

耗尽温柔 提交于 2019-12-21 12:15:23
问题 Supose the families bellow: The Build Schema of this is: create table PersonConn (child int, parent int) insert into PersonConn values (1,2) insert into PersonConn values (1,3) insert into PersonConn values (5,3) insert into PersonConn values (5,4) insert into PersonConn values (6,7) insert into PersonConn values (6,8) insert into PersonConn values (2,9) insert into PersonConn values (2,10) insert into PersonConn values (3,11) insert into PersonConn values (3,12) To get the ancestors of a

SQL Server Fragmentation Problems

谁说我不能喝 提交于 2019-12-21 12:05:41
问题 I have a couple of tables (User & UserRecord) in my database that get extremely fragmented (like 99%) and cause the whole database and therefore the website to grind to a halt. UserRecord is kind of like a snapshot of that user at a point in time. User is like the master record for that user. User has 0 to many UserRecords. User has around a million rows, UserRecord has around 2.5 million. These tables get written to a lot. They're also being searched a lot. They're both going to get a lot

SQL Server Fragmentation Problems

会有一股神秘感。 提交于 2019-12-21 12:05:11
问题 I have a couple of tables (User & UserRecord) in my database that get extremely fragmented (like 99%) and cause the whole database and therefore the website to grind to a halt. UserRecord is kind of like a snapshot of that user at a point in time. User is like the master record for that user. User has 0 to many UserRecords. User has around a million rows, UserRecord has around 2.5 million. These tables get written to a lot. They're also being searched a lot. They're both going to get a lot

Powershell - User Mapping SQL Server 2012

牧云@^-^@ 提交于 2019-12-21 11:33:05
问题 I am trying to script User Mapping for different Login accounts. I have scripted the creation of users and individual server roles, but I can't figure out how to set User Mapping with Powershell, I will also need to set the Database Role membership , in Particular, db_backupoperator Anyone know how to do this with Powershell? 回答1: Supposing your login is created ## Creating database user and assigning database role #get variables $instanceName = "yourInstance" $loginName = "testLogin"

Powershell - User Mapping SQL Server 2012

China☆狼群 提交于 2019-12-21 11:32:21
问题 I am trying to script User Mapping for different Login accounts. I have scripted the creation of users and individual server roles, but I can't figure out how to set User Mapping with Powershell, I will also need to set the Database Role membership , in Particular, db_backupoperator Anyone know how to do this with Powershell? 回答1: Supposing your login is created ## Creating database user and assigning database role #get variables $instanceName = "yourInstance" $loginName = "testLogin"

Table Valued Constructor Maximum rows limit in Select

a 夏天 提交于 2019-12-21 11:01:12
问题 I have a Table Valued Constructor through which am Selecting around 1 million records. It will be used to update another table. SELECT * FROM (VALUES (100,200,300), (100,200,300), (100,200,300), (100,200,300), ..... ..... --1 million records (100,200,300)) tc (proj_d, period_sid, val) Here is my original query : https://www.dropbox.com/s/ezomt80hsh36gws/TVC.txt?dl=0# When I do the above select it is simply showing Query completed with errors with showing any error message. Update : Tried to

Condense Time Periods with SQL

爱⌒轻易说出口 提交于 2019-12-21 09:07:38
问题 I have a large data set which for the purpose of this question has 3 fields: Group Identifier From Date To Date On any given row the From Date will always be less than the To Date but within each group the time periods (which are in no particular order) represented by the date pairs could overlap, be contained one within another, or even be identical. What I'd like to end up with is a query that condenses the results for each group down to just the continuous periods. For example a group that

How to view data in table variables during debugging session in MS SQL Management Studio 2012?

心不动则不痛 提交于 2019-12-21 07:14:03
问题 I would like to debug a complex T-SQL script using SSMS 2012. I can run the script in debug mode and place breakpoints, as well as step through my script, but I can't see the values stored in my table variables. In the Locals window I see all these variables, but their value is shown as (table) : There is no way to view the content of the variable through the context menu or by clicking on the variable. I tried to use the Immediate Window to run a query on the table variable, but this seems