ssms

SQL query, if value is null then return 1

末鹿安然 提交于 2019-12-03 06:28:22
问题 I have a query that is returning the exchange rate value set up in our system. Not every order will have an exchange rate (currate.currentrate) so it is returning null values. Can I get it to return 1 instead of null? Something like an if statement maybe: if isnull(currate.currentrate) then 1 else currate.currentrate Here is my query below. I greatly appreciate all your help! SELECT orderhed.ordernum, orderhed.orderdate, currrate.currencycode, currrate.currentrate FROM orderhed LEFT OUTER

How to automatically refresh the SQL Server Management Studio intellisense cache?

筅森魡賤 提交于 2019-12-03 06:22:42
问题 In SQL Server Management Studio if the user creates new table columns, tables, etc. the user needs to refresh the IntelliSense cache using CTRL + Shift + R . Is there a setting or some way to automate this so it can automatically be refreshed right after inserting a new table, etc? 回答1: I don't know that there is a way to automatically refresh the cache without manually pressing Ctrl + Shift + R (or equivalent, e.g. the menu). The reason is that when the app talks to the database too much,

SSMS Object Explorer - Select Top N Rows missing when connected to Azure DB

隐身守侯 提交于 2019-12-03 06:12:43
I just upgraded my SSMS to 2008 R2. I'm missing the option to select the top 1000 rows from a table, like this: Mine looks like this: I know how to change the number of rows that are displayed, but the options aren't there at all. I saw that someone submitted a bug for this a few years ago, but there was no workaround, and I'm not sure what to do. Any ideas? EDIT - Azure Problem? I just used SSMS to open my local SQL Server, and I get the option to select the top 100 rows. But in my other SSMS instance, the one that is connected to my Azure DB, I don't see it. Is it possibly an Azure

A valid destination folder for the install could not be determined when installing SQL Server Management Studio 2016

ぐ巨炮叔叔 提交于 2019-12-03 05:56:13
Whilst installing SSMS 2016, I get the following error and setup terminates: SQL Server 2016 Common Files: A valid destination folder for the install could not be determined. I've tried the following solutions: Delete all files in %TEMP% folder Check that BootstrapDir exists in HKLM The above 2 options where suggested on the MS sites. I have administrator privileges and I must also add that I have already installed SSMS 2016 on this machine but I removed it to clean up some space. Any ideas what I might look for to solve this problem? This is the exact error message I was getting:

How to insert a NEWID() / GUID / UUID into the code editor?

主宰稳场 提交于 2019-12-03 05:54:42
Many code editors have a built-in menu item or keyboard function to get a UUID, for example when I press CTRL + SHIFT + G in Delphi it inserts a GUID at the current position in the source code. I know that I can use SELECT NEWID() to generate a UUID, but I have to go to the query result, copy the generated UUID to my clipboard (killing whatever was in there before) and then go back to the code and replace the query which is an awful way of dealing with this. Is there any function (maybe using IntelliSense code snippets?) to do this in SQL Server Management Studio that I haven't found yet? Some

SQL Server copy all rows from one table into another i.e duplicate table

泪湿孤枕 提交于 2019-12-03 04:43:54
I want to keep a table as history and replace it with an empty one. How can I do this through Management Studio? froadie Duplicate your table into a table to be archived: SELECT * INTO ArchiveTable FROM MyTable Delete all entries in your table: DELETE * FROM MyTable Don't have sql server around to test but I think it's just: insert into newtable select * from oldtable; select * into x_history from your_table_here; truncate table your_table_here; Either you can use RAW SQL: INSERT INTO DEST_TABLE (Field1, Field2) SELECT Source_Field1, Source_Field2 FROM SOURCE_TABLE Or use the wizard: Right

CTRL+R does not hide the Query Result window in SSMS

…衆ロ難τιáo~ 提交于 2019-12-03 04:41:09
问题 I just upgraded from SSMS 2005 to 2012. Previously, I could hit CTRL + R and the Query Results windows would disappear. After I upgraded to SSMS I ran a query and, out of habit, hit CTRL + R . Nothing happened. At the bottom of SSMS I noticed that the status bar was reporting "(Ctrl+R) was pressed. Waiting for the second key of chord..." After checking out the details of this keyboard shortcut in the MSDN documentation, I found out that CTRL + R was suppose to hide the resulting window as I

SQL Server Express 'NEW TRIGGER' BUTTON IS DISABLED

亡梦爱人 提交于 2019-12-03 04:36:08
I am new to SQL Server Express and I want to create a new trigger on my table. But I found that the 'New trigger' button in my table's trigger folder shows Disabled. When I right click on trigger folder it shows 'New trigger' button disabled and in gray color. I am using SQL Server 2014 Express and Management Studio 2014. Does anybody have any idea why it is happening? Please suggest me some way out. This a known issue (bug) with SSMS 2014. Reference : https://connect.microsoft.com/SQLServer/feedback/details/873249/ssms-2014-new-trigger-is-disabled-for-older-2012-2008r2-versions-of-sql-server

Duplicating a TABLE using Microsoft SQL Server Mangement

不羁岁月 提交于 2019-12-03 04:22:54
Need to duplicate a TABLE using Microsoft SQL Management Studio 2008 The TABLE needs to duplicate all table row (Primary Key) ID as well. Thanks. SQLMenace In SSMS open a new query window and then do something like SELECT * INTO NewTable FROM OldTable change NewTable to the name that the new table should have, change OldTable to the name of the current table this will copy over the basic table structure and all the data...it will NOT do any of the constraints, you need to script those out and change the names in those scripts I prefere the copy / paste solution as it is documented here . It

SQL Server Management Studio Skin / Appearance / Layout

折月煮酒 提交于 2019-12-03 04:12:51
Can you apply a custom skin / appearance to SSMS? I am thinking something along the lines of a dark theme (black background, yellow font) you'd find in most IDEs NateJ SSMS 2012 is build on the VS 2010 shell. Thus, it can use compatible ".vssettings" files to apply custom color schemes. See also http://studiostyl.es/ for a gallery. mycargus I decided to try something simple on SSMS 2012 : Go to http://studiostyl.es/ Pick a theme and download it Follow these screenshot instructions Note that doing this will only affect the theme of the text editor, not the toolbar, menu, object explorer window,