Skip to main content

Questions tagged [output-clause]

11 votes
2 answers
586 views

I have 2 tables with the cascade delete rule - [dbo].[Invoices] and [dbo].[InvoiceRows]: CREATE TABLE [dbo].[Invoices] ( [InvoiceId] [int] IDENTITY(1,1) NOT NULL, --other columns ...
mrigrek74's user avatar
  • 113
0 votes
2 answers
302 views

I am trying to get SQL version from a linked server and save it in a variable, but the query runs fine and showed me the result but when I review the output variable is Null. DECLARE @cmd NVARCHAR(MAX)...
Carlos Zavala's user avatar
8 votes
2 answers
961 views

Consider the following minimal, complete, and verifiable example code (see dbfiddle here): CREATE TABLE [dbo].[test] ( [i] bigint NOT NULL identity(1,1) PRIMARY KEY CLUSTERED ...
Hannah Vernon's user avatar
  • 71.1k
0 votes
1 answer
725 views

1.) @MULTIPLE_RESULTS_TABLEVAR has fields (x, y, OrdersTableID) and values: [a,b,Null], [c,d,Null], [e,f,Null] 2.) Goal is to bulk insert @MULTIPLE_RESULTS_TABLEVAR data into an OrdersTable having ...
M S's user avatar
  • 21
0 votes
1 answer
109 views

For a mature .Net project I support we're currently exploring options to remove Entity Framework Core from the project while still maintaining some of the EF functionality we rely on. At the top of ...
Adrian's user avatar
  • 103
0 votes
1 answer
949 views

I have a relatively simple question with an implied answer, but not an explicit one. Here's the background. Here are the 3 schemas I'm working with: --Source Data: ProjectID, ProjectName, CompanyName ...
Vocoder's user avatar
  • 117
7 votes
1 answer
572 views

Is there an undocumented restriction in the OUTPUT clause, or is this a bug? Given the following table: CREATE TABLE t1 (SomeId int, flag bit, value int); I would like to use a calculated value in an ...
Charlieface's user avatar
  • 18.1k
-4 votes
1 answer
136 views

Find all 5 errors in the SQL script below and explain what the script is trying to do select A.BIZ_DT, A.ACTL_PARENT_SVC_NUM, A.DIRCTN_IND, A.BUS_STOP_CD, A.BUS_STOP_ARRVL_TM, A.OPR_ID_NUM, A.REG_NUM, ...
Wen Hui Wong's user avatar
2 votes
2 answers
6k views

I want to add a record to my app's "SystemSettings" table and set the PK value using the value from an UPDATE. The PK value comes from the "TS_LASTIDS" table which contains the maximum PK value for ...
mnemotronic's user avatar
2 votes
1 answer
285 views

I know that the output parameter does not guarantees parallelism logic. And the logic I want to implement is failing in a multi thread environment. To test this, just open 2 windows and execute them ...
Dryadwoods's user avatar
2 votes
1 answer
5k views

How do you retrieve the identity value for an inserted row when that row is inserted from the OUTPUT of an UPDATE statement? Neither @@IDENTITY nor SCOPE_IDENTITY() appears to be set properly. ...
Riley Major's user avatar
  • 1,955
3 votes
1 answer
10k views

I need to make three select queries over three different tables, using the outputs of each select query, the catch is each one gives multiple results. Here is how I do it. Select "Title", "Num" from "...
EvsizTospaa's user avatar
34 votes
2 answers
34k views

I am writing a batch processing insert statement and would like to use a temp table to keep track of inserted ID's instead of looping through the items myself and calling SCOPE_IDENTITY() for each ...
Louis Somers's user avatar
0 votes
1 answer
429 views

insert Table1 OUTPUT inserted.ID, s.[Id] INTO @Inserted select s.[Field1], s.[Field2], from @TableVariable s why is s.[Id] marked by red line ? Is it non-correct syntax to save value in @Inserted ...
Vladyslav Furdak's user avatar
2 votes
1 answer
887 views

Using SQL Server 2008R2. I have a single table with a bunch of columns. I have built a new database with multiple tables to copy the data too. How do I copy the data, and still keep the ...
BattlFrog's user avatar
  • 183

15 30 50 per page