sql-server-2008-r2

How to execute a stored procedure against linked server?

蹲街弑〆低调 提交于 2019-12-21 09:28:59
问题 We currently execute a stored procedure against a linked server using: EXECUTE [LinkedServer].[DatabaseName].[dbo].[MyProcedure] For example: EXECUTE Screwdriver.CRM.dbo.GetCustomer 619 And this works fine; querying through a linked server works fine. Disabling the deprecated "Remote Access" feature There is apparently a little known, seldom used, feature known as remote access . Microsoft has very little to say about what this feature is , except to say here: This configuration option is an

Using OUTPUT after INSERT to get value of identity column into a (non-table value) variable

二次信任 提交于 2019-12-21 08:31:11
问题 Given the following simple test table: CREATE TABLE dbo.Test ( Id bigint IDENTITY(1,1) NOT NULL, Name varchar(50) NULL ) I would like to get the value of the identity column into a scalar variable after the INSERT using the OUTPUT clause, but this does not work: DECLARE @InsertedId BIGINT; INSERT INTO Test(Name) OUTPUT @InsertedId=inserted.Id VALUES ('Michael') -- Display resulting id for debugging SELECT @InsertedId; -- ... I know I can easily do this using SCOPE_IDENTITY() after the INSERT

Select values from multiple columns into single column

好久不见. 提交于 2019-12-21 07:24:20
问题 I have a table in a database that has 9 columns containing the same sort of data, these values are allowed to be null . I need to select each of the non-null values into a single column of values that don't care about the identity of the row from which they originated. So, for a table that looks like this: +---------+------+--------+------+ | Id | I1 | I2 | I3 | +---------+------+--------+------+ | 1 | x1 | x2 | x7 | | 2 | x3 | null | x8 | | 3 | null | null | null| | 4 | x4 | x5 | null| | 5 |

Insert a circle into geometry data type

折月煮酒 提交于 2019-12-21 06:34:50
问题 I'm about to start using geometry or geography data types for the first time now that we have a development baseline of 2008R2 (!) I'm struggling to find how to store the representation for a circle. We currently have the lat and long of the centre of the circle along with the radius, something like :- [Lat] [float] NOT NULL, [Long] [float] NOT NULL, [Radius] [decimal](9, 4) NOT NULL, Does anyone know the equivalent way to store this using the STGeomFromText method, ie which Well-Known Text

Insert a circle into geometry data type

你离开我真会死。 提交于 2019-12-21 06:30:18
问题 I'm about to start using geometry or geography data types for the first time now that we have a development baseline of 2008R2 (!) I'm struggling to find how to store the representation for a circle. We currently have the lat and long of the centre of the circle along with the radius, something like :- [Lat] [float] NOT NULL, [Long] [float] NOT NULL, [Radius] [decimal](9, 4) NOT NULL, Does anyone know the equivalent way to store this using the STGeomFromText method, ie which Well-Known Text

View joining with stored Procedure results

无人久伴 提交于 2019-12-21 05:35:25
问题 I have a existing view in SQL server used by the application. I need to join with table returned from the stored procedure. The stored procedure does lot of things like inserting to multiple #temp tables before returning the result. I tried to convert the stored procedure to Table valued function. But inserting to temp table inside the TVF causes compilation error. Is there any other way I can achieve this. Thanks 回答1: You can insert the results from the Stored Procedure into a temp table,

Xml Parsing Issue in sql job

痞子三分冷 提交于 2019-12-21 05:30:54
问题 I am getting an error while executing the query in a SQL Server job. But if I execute it directly, it works fine. Executed as user: NT AUTHORITY\SYSTEM. XML parsing: line 10, character 33 Unexpected end of input [SQLSTATE 42000] (Error 9400). The step failed. SQL Severity 16, SQL Message ID 9400 Code: declare @URL VARCHAR(max) set @url = 'http://www.spa.gov.sa/english/rss.xml' declare @xmlT TABLE (yourXML XML) DECLARE @Response nvarchar(max) DECLARE @XML xml DECLARE @Obj int DECLARE @Result

T-SQL Is it possible to do an Update / Insert with a single fast operation

痞子三分冷 提交于 2019-12-21 04:56:08
问题 Let's say I have a table and I want to insert a row. The new row's key may already match an existing row's key in the table, in which case I want to update the existing row. Or, it may not exist in the table, in which case the new row should be inserted. What is the most efficient way to perform such an operation? I was thinking of first doing a SELECT (perhaps with EXISTS ) to see if a particular key is present, followed by an UPDATE if present and an INSERT if not. You would probably need

How to determine which SSAS Cube is processing now?

牧云@^-^@ 提交于 2019-12-21 04:22:05
问题 There is a problem when several users can process the same cube simultaniously and as a result processing of cube fails. So I need to check if certain cube is processing at current moment. 回答1: I dont think you can prevent a cube from being processed if someone else is already processing it. What you can do to "help" is run a MDX query to check the last time the cube was processed: SELECT CUBE_NAME, LAST_DATA_UPDATE FROM $System.MDSCHEMA_CUBES or check the sys.process table on the realted sql

Keep report header visible while scrolling

浪子不回头ぞ 提交于 2019-12-21 04:12:43
问题 I often check the following option in the hope that it will be implemented when the report is rendered on the RS web portal - but it never works... The reports usually have some Row Groups - does this have an impact on whether this option will work? Or is this a bug in Reporting Services ? 回答1: I find it usually doesnt work as advertised and you have to find the "Advanced mode" button (a strong candidate for the worst piece of UI ever) and then fiddle with several properties. Here's probably