ssms

Money Data Type Precision - SQL Server (SSMS)

北慕城南 提交于 2019-12-06 11:55:31
In sql server management studio, data type- money, when I enter an amount with a decimal it automatically adds on zeros to fill up to the hundredths. How can I determine the amount of spaces after the decimal? The number of zeroes behind the dot is called the precision of a datatype. The money data type has a fixed precision : with accuracy to a ten-thousandth of a monetary unit. That's five digits behind the dot. If you'd like a different precision, use the decimal datatype. Some examples: select cast(0.123456789 as money) , cast(0.123456789 as decimal(5,3)) , cast(0.123456789 as decimal(5,1)

show Create commands for table in SQL Management Studio (2008)

筅森魡賤 提交于 2019-12-06 11:53:13
I've just started with SQL Management Studio and I am wondering if I can show create commands for already existing tables, I've been able to do that in Oracle SQL Developer.. I've tried to ask uncle google but maybe used just wrong search command.. Anyway.. could someone give me quick hint as I stuck with this for like 25 minutes? Thanks In Object Explorer, expand your server/database, expand Tables, right-click the table in question, and choose Script Table as > CREATE To > New Query Editor Window. If you want to script multiple tables, you can turn on Object Explorer Details (F7 or from the

SQL Server Management Studio won't work after Windows Update

淺唱寂寞╮ 提交于 2019-12-06 09:54:59
问题 Came to work this morning, my PC (Win7 x64) had force rebooted by Windows Update. Now, SQL Server Management Studio (SQL Server 2008 r2) fails when connecting to a database and trying to expand the tree view, citing: Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.VisualStudio.OLE.Interop.IServiceProvider'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{6D5140C1-7436-11CE-8034-00AA006009FA}' failed

SQL Server: How to attach / repair a detached / damaged database?

馋奶兔 提交于 2019-12-06 04:30:40
A database server crashed. I was able to get the mdf and the log file and I am trying to mount it on another server. I don't have backup as it was a development database. When I try to attach the mdf and ldf files, Sql Server Management Studio give me this error: TITLE: Microsoft SQL Server Management Studio ------------------------------ Attach database failed for Server ------------------------------ Could not redo log record (457:14202:19), for transaction ID (0:478674), on page (1:519205), database 'WSS_Content_5555' (database ID 15). Page: LSN = (370:463:113), type = 1. Log: OpCode = 2,

Deleting duplicates based on multiple columns

时光怂恿深爱的人放手 提交于 2019-12-06 03:05:48
问题 I have listed duplicates using the following: select s.MessageId, t.* from Message s join ( select ToUserId, FromUserId, count(*) as qty from Message group by ToUserId, FromUserId having count(*) > 1 ) t on s.ToUserId = t.ToUserId and s.FromUserId = t.FromUserId Now, how do I delete all but one of the Messages (I'm trying to remove duplicates so I can apply a unique index on FromUserId and ToUserId ). 回答1: Use a cte and assign row numbers so that all but one for duplicate pairs can be deleted

How to determine the effective permissions for a user of a SQL Server database through C#?

夙愿已清 提交于 2019-12-05 23:53:17
问题 When I say effective permissions, I'm referring to the permissions listed when you go into the properties of a database in SQL Server Management Studio, click "Permissions", and then click the "Effective" tab. So far, I have been able to determine the explicit permissions with the following code: using Microsoft.SqlServer.Management.Smo; ... DatabasePermissionInfo[] permissions = database.EnumDatabasePermissions("username"); However, I still need to obtain the effective permissions. In this

SQL Server 2008 R2 standard missing “Audits” folder in SSMS?

佐手、 提交于 2019-12-05 23:14:44
I will pre-cursor this with the fact that I am NOT a DBA! I am trying to set up auditing on an SQL Server 2008 R2 Standard edition, but the Audits folder is missing from the Security section. Is this a version issue associated with the "fine-grained auditing" that is only in the Enterprise and DataCenter editions? Any help is greatly appreciated! According to Features Supported by the Editions of SQL Server 2008 R2 auditing is only available in 2008 / 2008 R2 Enterprise / Datacenter. According to Features Supported by the Editions of SQL Server 2012 auditing has been split up in SQL Server

“Favorites” or “macros” in SQL Server Management studio?

不羁的心 提交于 2019-12-05 21:41:57
问题 I have a few databases that I always use SQL Server Management Studio with. I'd like to be able to create a toolbar button or keyboard shortcut that automatically opens a new query window (in the current SSMS instance) and connects to a given (registered, perhaps) database. That's it. That's all I need. And this ashtray, and the paddle game, and the remote control. That's all I need. As it is now, I have to expand the Object Explorer, collapse/expand two to eight trees, right-click on my

Bypassing character limit on OPENQUERY failing use EXECUTE

橙三吉。 提交于 2019-12-05 19:03:43
I am currently using SQL Server Management Studio 17 to connect to an Oracle database instance and then extract some data and insert it into a SQL Server Table I have. I have tried doing the following: DROP TABLE IF EXISTS [jerry].[dbo].[purchases] SELECT * INTO [jerry].[dbo].[purchases] FROM OPENQUERY(OLAP, ' proprietary sql code '); However the SQL code is about 9500 characters and thus OPENQUERY fails, which is supported by MSDN articles I referenced these sites: - MSDN One - MSDN Two and learned that I can use EXEC to accomplish my goal. I have tried to implement the following: EXEC master

Limit Database List to Ones With Permission SQL Server

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-05 17:47:05
By default if you connect to a remote SQL Server via an account that has access to say 1 of the 10 databases. You will still see in the Object Explorer all other databases, obviously due to permissions you cannot actually query them, but you can see their names. I have heard that there is a method that disable this behavior, but I've been unable to find the answer, does anyone know how to do this? To give an example I have a SQL Server called MyDbServer, it has 4 databases, MyDatabase YourDatabse PrivateDatabase ReallyPrivateDb If you connect via an account that only has permissions to