ssms

Why isn't SSMS honoring my default database settings?

我与影子孤独终老i 提交于 2019-12-11 04:39:17
问题 For some reason SSMS isn't honoring my default database setting. I have set my default database using Exec sp_defaultdb @loginame='[username]', @defdb='[database_name]' or by using Security > Logins > [my login] > Properties > Default Database This seemed to have started when I took my default database offline and then couldn't log in. I had to use sp_defaultdb to change to another database until I could bring it back online. Now it just goes to master, even though it's set to my default db

Split string via select statement

眉间皱痕 提交于 2019-12-11 04:21:11
问题 Fairly simple question, but seems impossibe to get an answer. If I have this: declare @Agent nvarchar(4000) = '2131235,334225'; Is there a select statement I can write to split the string where the coma is, WITHOUT having to write a function? Something like: SELECT SOME_SPLIT_LOGIC(@Agent) I would like it to return: Column -------- 2131235 334225 Please note I am use MS-SQL 2012 回答1: DECLARE @LeftPart TABLE (Agent int ) DECLARE @RightPart TABLE (Agent1 int ) declare @Agent nvarchar(4000) =

SQL Server 2008 - Attach mdf without log - Operating system error 5: 5(Access is denied.)

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 04:17:02
问题 I am trying to attach database without log file. Attach a SQL Server database with a missing transaction log file Error on SSMS Error on TSL Msg 5120, Level 16, State 101, Line 1 Unable to open the physical file "....mdf". Operating system error 5: "5(Access is denied.)". I'm not sa, but I'm in sysadmin role. I'm not really sure what access permission I need. Or is it because the .mdf is corrupted? Thank in advance! 回答1: That's a bug in the SSMS interface. It can be done using T-SQL. Just don

Is there a way to select last N columns in SQL Server Results Tab?

徘徊边缘 提交于 2019-12-11 04:06:04
问题 Shortly, I don't mean the last 5 rows. via SELECT TOP 5 * FROM Table Order By Key DESC But I mean last 5 columns in Results Tab. Why? because each time I add a new column and filling it outside SQL-Server, I need to see its result without moving Horizontal Scroll. and many columns have the same name at the beginning. It's not coding issues. but it's about the SQL-Server IDE Results tab itself. I Searched many times. but this thing never asked I think. so please I want an approach for that. I

SQL Server Management studio won't start - Type library could not be found

这一生的挚爱 提交于 2019-12-11 04:01:58
问题 I am running SQL Server Management Studio Developer Edition 2012, and the program would not start this morning. I have tried everything online, but to no avail. When I (attempt to) start the application, i am greeted with a message: "The proper type library could not be found in the system registry An attempt to repair this condition failed because you do not have the permissions to write tot he system registry or because thetype library could not be loaded" If i click "ok" on this message,

Combine select top 1 SQL Statements

筅森魡賤 提交于 2019-12-11 03:43:01
问题 I have 4 select statements: SELECT top 1 software, auditDate, versionNumber FROM table1 where software = 'software1' order by auditDate desc SELECT top 1 software, auditDate, versionNumber FROM table1 where software = 'software2' order by auditDate desc SELECT top 1 software, auditDate, versionNumber FROM table1 where software = 'software3' order by auditDate desc SELECT top 1 software, auditDate, versionNumber FROM table1 where software = 'software4' order by auditDate desc Currently, each

How do i set password to zip file in SSIS?

这一生的挚爱 提交于 2019-12-11 01:40:39
问题 I have compressed file by 7-zip using Execute Process Task in SSIS. Now i have to set password to zip file How can i achieve that ? 回答1: I dont think this is a ssis issue. You have to take a look at 7zip command line user guide and check if this option is provided. Also there are other useful links: https://www.dotnetperls.com/7-zip-examples Update 1 I think this is the link you are looking for https://sevenzip.osdn.jp/chm/cmdline/switches/password.htm 来源: https://stackoverflow.com/questions

SQL Server Management Studio won't connect to Sql Server

梦想与她 提交于 2019-12-11 01:28:40
问题 I've installed Visual Web Developer 2010, SQL Server 2008 R2 and SQL Management Studio 2008, using the MS Web Platform Installer 2.0. But whenever I wanna login, with Windows Authentication , to SQL Server with the Sql Management Studio it throws me an error: Cannot connect to (local) And then under that, it says that it can't find the server or it can't access it. I used to use the Sql Management Studio 2005 before and I could connect easily. But with this version it seems there are some

Incorrect syntax near 'for' SQL Server

久未见 提交于 2019-12-11 00:28:50
问题 I want to add a new Column to an existing Table that has already Data in it. The Column should be NOT NULL. Because of that i want to set a Default Value. But when i do it throws the following exception: "Incorrect syntax near 'for'" ALTER TABLE Semester ADD SIDNew uniqueidentifier NOT NULL CONSTRAINT DF_SIDNew DEFAULT '00000000-0000-0000-0000-000000000000' FOR SIDNew I already had a look at How to set a default value for an existing column and Incorrect syntax near the keyword 'FOR' but none

Unable to export my .xlsx to my Sql server 2008 database

↘锁芯ラ 提交于 2019-12-10 23:59:17
问题 I have an excel sheet .xlsx extension with around 500,000 row and 16 columns. and i want to import it inside our sql server database which runs under windows server 2008 R2 . so i tried the following steps inside my SQL Server Management studio 2008 R2 , but they did not work:- i created a new database which have the same 16 columns + i add a new ID column and i set it as the Primary key. then i right click on the database > Tasks >> Import Data i select excel sheet 2007 >> browse for the