ssms

Save output of multiple queries into file?

大城市里の小女人 提交于 2020-06-12 03:33:06
问题 I have a SQL query that I have to run against multiple (15) tables in SQL Server Management Studio . Is it possible to save the result of multiple queries into a file? (.txt, excel sheet?) Using union is not possible because not all tables have an equal amount of columns. The queries look somewhat like this select * from tableA where main_id in (select id from maintable where date is null and status ='new') select * from tableB where main_id in (select id from maintable where date is null and

How can I execute a set of .SQL files from within SSMS?

梦想的初衷 提交于 2020-06-09 08:36:27
问题 How could I execute a set of .SQL files (each does some data transformations) from within SQL Server Management Studio? What other alternative are there for executing .SQL files in batch? 回答1: While SQLCMD.exe is the best way, SSMS also has a SQLCMD mode where you can execute a SQLCMD script. To enable this mode click Query in menu bar then select SQLCMD Mode . The ":r filename.sql" command is the SQLCMD script command to import and execute a sql script file. You know you are in SQLCMD mode

How can I execute a set of .SQL files from within SSMS?

丶灬走出姿态 提交于 2020-06-09 08:36:27
问题 How could I execute a set of .SQL files (each does some data transformations) from within SQL Server Management Studio? What other alternative are there for executing .SQL files in batch? 回答1: While SQLCMD.exe is the best way, SSMS also has a SQLCMD mode where you can execute a SQLCMD script. To enable this mode click Query in menu bar then select SQLCMD Mode . The ":r filename.sql" command is the SQLCMD script command to import and execute a sql script file. You know you are in SQLCMD mode

SQLSMS Intellisense on linked server

时间秒杀一切 提交于 2020-06-08 17:37:06
问题 I'm trying to work Microsoft SQL Server Management Studio 10.0.5538.0 (latest right now) with Intellisense on linked servers, for example: SELECT Column FROM [LinkedServer].DatabaseName.dbo.Table WITH(NOLOCK) But I couldn't find a way to make intellisense show results as I write SQL code (it works fine with non-linked servers) Things I've tried: Look for answers in SQLSMS docs. Look for specific config option in the application. Update local cache in Edit -> IntelliSense -> Refresh local

Export tables in SSMS and import them onto a different server

时光毁灭记忆、已成空白 提交于 2020-06-01 04:59:49
问题 We have clients that run a particular piece of software with a large SQL Server database and they use SSMS to manage it (we don't want to ask them to install any other software on their servers). We need to get a number of tables out of the server using SSMS so they can save them (this has to be a relatively easy process, it will be an IT manager not a DBA or programmer doing the task) and send them to us (on usb drive). So I have experimented with the generate script option, but in the test

SSIS - the RPC server is unavailable

情到浓时终转凉″ 提交于 2020-05-15 02:56:46
问题 I've installed a instance of SQL Server and i select Integration Services in the setup wizard. However, when I run SQL Server Management Studio as 'Administrator', I can see my instance under. Database Engine Analysis Services Reporting Services However, I can't see my instance under 'Integration Services'. The service is running in Configuration Manager. UPDATE 1 When trying to enter the server name manually it gives the following error: the RPC server is unavailable 回答1: If you means this

What might cause SSMS queries to reflect incorrect data and how can we clear the problem?

放肆的年华 提交于 2020-04-30 09:26:12
问题 I have never experienced this before. SSMS is displaying data tables incorrectly. SSMS seems to be locked into some previous query result and I don't see how to clear it. I have an application (MVC) that interfaces to an SQL server. When I run the application's database data delete function, the application shows the table to be empty. But SSMS still shows data in the table. If I then run the application's database seed function, the application shows the table to be re-loaded and I can tell

SSMS: How to import (Copy/Paste) data from excel

 ̄綄美尐妖づ 提交于 2020-04-28 22:45:12
问题 How to Copy/Paste following delimited data (by default delimited with tab) from excel: declare @t_values nvarchar(max) = N' NULL 490366 NULL NULL NULL 490400 NULL NULL NULL 490402 NULL NULL 483061 490404 10 abc1 NULL 490406 NULL NULL 9766167 490408 3 abc2' ; To my temp table: CREATE TABLE #insertTable ( transaction_id int ,user_id int ,purchase_price decimal(8,2) ,mess varchar(8) ); ? NB! Without using OPENROWSET SOLUTIONS : QUERY PROCEDURE SNIPPET (fast way to creae snippets HERE) P.S. If

Snippet to create Snippet in SSMS

☆樱花仙子☆ 提交于 2020-04-17 22:52:16
问题 Problem: Usually, if you want to save your code as a snippet, you have to open some xml template, investigate tags etc. Reference Is it possible to simplify this process as much as possible: i.e. create a SurroundsWith snippet that will wrap selected code by snippet code? 回答1: Please try following: Save this code as a create_new_snippet.snippet and add it to your SSMS through code snippet manager (Ctrl+K, Ctrk+B) <?xml version="1.0" encoding="utf-8" ?> <CodeSnippets xmlns="http://schemas

Setup a Trigger on Table to limit the number of INSERT, DELETE, UPDATE Operations

柔情痞子 提交于 2020-04-17 22:00:06
问题 For example : A user should not be able to perform INSERT , DELETE and UPDATE operations more than X number of times on a particular table at a given point of time, if the user performs an operation X +1 times than a trigger will be launched. 回答1: create table dbo.targetTable ( id int, colA varchar(10) ); go create or alter trigger dbo.DMLxTimes on dbo.targetTable for insert, update, delete as begin /* --old days.. IF @@ROWCOUNT > 5 begin rollback; end --*/ declare @maxrows int = 5; --maximum