ssms

How to convert TIMESTAMP values to VARCHAR in T-SQL as SSMS does?

◇◆丶佛笑我妖孽 提交于 2019-12-08 15:09:11
问题 I am trying to convert a TIMESTAMP field in a table to a string so that it can be printed or executed as part of dynamic SQL. SSMS is able to do it, so there must be a built-in method to do it. However, I can't get it to work using T-SQL. The following correctly displays a table result: SELECT TOP 1 RowVersion FROM MyTable It shows 0x00000000288D17AE . However, I need the result to be part of a larger string. DECLARE @res VARCHAR(MAX) = (SELECT TOP 1 'test' + CONVERT(BINARY(8), RowVersion)

Resultset column width in Management Studio

自古美人都是妖i 提交于 2019-12-08 14:37:54
问题 Is there any way to alter the column width of a resultset in SQL Server 2005 Management Studio? I have a column which contains a sentence, which gets cut off although there is screen space. | foo | foo2 | description | | foo | foo2 | description | |--------------------------| TO |----------------------------------| | x | yz | An Exampl.. | | x | yz | An Example sentence | I would like to be able to set the column size via code so this change migrates to other SSMS instances with the code. 回答1

Deterministic Scalar Functions

China☆狼群 提交于 2019-12-08 11:01:57
问题 I want to index a computed column in my database table which uses a number of user defined functions. However I just learned that my column is non-deterministic. Without indexing its going to be way to slow to run queries that I need. What's the best way of tracing through user defined functions to determine whether they are deterministic? Is there any kind of tool in SQL Server Management Studio that will tell me whether a user defined function is deterministic or do I just need to trace

How to run sqlcmd remotely on a machine which does not have SSMS

假装没事ソ 提交于 2019-12-08 09:54:32
问题 Is there a way in which we can run sqlcmd on a machine without having SSMS. 回答1: If you follow this link for Microsoft SQL Server 2008 R2 Feature Pack , you should be able to download it for the machine without needing to install SQL server. Also, see this link for Microsoft Command Line Utilities 11 for SQL Server which might be better. 来源: https://stackoverflow.com/questions/18872387/how-to-run-sqlcmd-remotely-on-a-machine-which-does-not-have-ssms

SQL Server ISNUMERIC() Clarification

非 Y 不嫁゛ 提交于 2019-12-08 07:37:40
问题 I have a table X with a list of accountNo's. This field(accoutNo) is a nvarchar(8). Now issue here is sometimes we get characters in this field as well and I want to convert it into bigint. Sorry I'am not able to put this in a table format here. I'am able to check if a accountNo is a numeric value or not: select x.accountNo from x where ISNUMERIC(x.accountNo)=1 but when I try to only convert the values if an accountNo is numeric, I still can't, I'm confused: select x.accountNo, convert(bigint

Why are there gaps in my IDENTITY column? [duplicate]

落花浮王杯 提交于 2019-12-08 07:29:28
问题 This question already has answers here : Why are there gaps in my IDENTITY column values? (7 answers) Closed 6 years ago . My table works fine if I enter data correctly - I can insert data and the IDENTITY values are 1, 2, 3, 4. However, if I make a mistake and get an error message, e.g. Cannot insert the value NULL into column 'x', table 'table'; column does not allow nulls. INSERT fails. The statement has been terminated. Then if I insert another row successfully, the IDENTITY value is 6,

Possible steps to improve SQL Server query performance

丶灬走出姿态 提交于 2019-12-08 07:07:09
问题 I have a search procedure that is being passed around 15-20 (optional) parameters and the search procedure calls their respective functions to check if the value passed in parameter exists in the database. So, it is basically a Search structure based on a number of parameters. Now, since the database is going to have millions of records, I expect the simple plain search procedure to fail right away. What are the ways that can improve query performance? What I have tried so far: Clustered

Intellisense is not working in SQL Server 2014

浪子不回头ぞ 提交于 2019-12-08 03:32:44
问题 Intellisense is not working in Microsoft SQL Server 2014, it was working fine in Microsoft SQL Server 2012 but once I installed 2014 it is not working. Under Tools -> Options -> Text Editor -> Transact-SQL -> IntelliSense it says it is enabled there. I have also tried refeshing the IntelliSense cache with Ctrl-Shft-R but that doesn't work. 回答1: From my personal experience, SSMS IntelliSense is a pure crap, sometimes it works, sometimes it doesn't. I'd go for third party tools. If you're

SSMS removing pre-BEGIN comments from my stored procedures

限于喜欢 提交于 2019-12-08 03:04:16
问题 I'm running SSMS 12.0.2000.8 If I use the SSMS query editor to create a stored procedure (such as the one below) the comments before BEGIN are removed when I execute/save it: CREATE PROCEDURE myproc /* Say goodbye to this comment */ @var1 int -- this comment will disappear too AS BEGIN /* This comment is safe */ select 'hello' -- this too shall endure END A colleague is running the same version of SSMS and has no such problems. If I execute one of his scripts using sqlcmd.exe the comments get

Money Data Type Precision - SQL Server (SSMS)

巧了我就是萌 提交于 2019-12-07 22:46:35
问题 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? 回答1: 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