Skip to main content
Filter by
Sorted by
Tagged with
0 votes
1 answer
47 views

I ask for your help with the feeling of despair after having tried to ask help internally in my company and tried all the IA models out there without success for my problem. So, basically, i want to ...
Joaolopes's user avatar
1 vote
2 answers
151 views

I'm working on a SQL Server query where I need to perform the following tasks efficiently: Execute a complex and resource-intensive SELECT statement to retrieve a subset of rows. Update same table ...
ssvt's user avatar
  • 31
0 votes
1 answer
468 views

I'm building an app on PowerApps, its a form that is normally completed on paper. I've built the app and have the functionality of it working within the canvas but trying to save the collected ...
user3599946's user avatar
3 votes
1 answer
138 views

I clearly misunderstand the difference between a batch and a session. I believe three things that cannot all be true at the same time: It is very well known that table variable only have the scope of ...
J. Mini's user avatar
  • 1,764
1 vote
1 answer
376 views

Need to Generate Tag Number While Inserting Data using JSON in SQl Server Stored Procedure. I have 2 Tables Table1: Category (lastusedIndex null in initial stage) Id categoryname assetPrefix ...
Relax's user avatar
  • 327
1 vote
1 answer
726 views

SQL Server does not maintain statistics for table variable and it always estimates 1 output row. Microsoft changed this behavior post release of SQL Server 2019. Though I am not able to find much ...
KnowledgeSeeeker's user avatar
0 votes
0 answers
324 views

Goal: Create a table (Changes) to record any changes that take place within a db with the following information: Schema Table ColumnChanged DeletedValue InsertedValue When creating the triggers for ...
HelpImdumb's user avatar
0 votes
2 answers
595 views

I have to update two temp tables @tbNewEntry and @tbUpdateEntry from another temp table @OnlineDataBase (I got the Data from online into this table) based on some conditions. Conditions to update: ...
Lax's user avatar
  • 51
-2 votes
1 answer
705 views

I have this stored procedure: Lemma 1: exec GetData 1, '20220301', 1 I run it with 1 as one of the parameters, It does correctly return some data Lemma 2: exec GetData 1, '20220301', 15 I run it with ...
ZentiumX's user avatar
  • 122
0 votes
0 answers
476 views

My question is similar to this. I made a scalar function like follows: CREATE FUNCTION [dbo].[MyFunction](@table [TableModel] READONLY) RETURNS DECIMAL(18, 6) AS BEGIN DECLARE @sql NVARCHAR(MAX), @...
Bruno Ramirez's user avatar
0 votes
0 answers
551 views

If I switch out the @GameIds table variable with the #GameIds temp table in the bottom query I get a full table scan on some tables, making a longer execution time, and large memory grant warning. I ...
Mike Flynn's user avatar
  • 23.4k
1 vote
0 answers
33 views

I'm trying to create a procedure in SQL Server to allow me to update a column on a table. However, I want the table name to come from a variable instead of being given by me, but I get an error ...
risan's user avatar
  • 11
-1 votes
1 answer
297 views

SQL Questions: Is this insert query is good in performance ? UserIds List is variable, its length mybe 10, 20 ... till 500. WITH Users AS (SELECT [Id] from [electro].[User] Where [Id] IN (4438,...
Ahmed Atef's user avatar
0 votes
1 answer
258 views

I have used the below SQL script to perform dynamic pivot. I want to use the result to left join on another table, but the "INTO" method does not seem to work for the table variable @query. ...
cheunghm4532's user avatar
0 votes
2 answers
939 views

I have a server log file that I am trying to pare down for easier inspection. The table I am searching through is from just doing a bulk insert into a single column table named Spam.LogData. One big ...
Ryan Gilbert's user avatar
1 vote
2 answers
286 views

I'm trying to use a @List Table to feed a Where IN statement. I keep getting the error, "Must Declare the scalar variable "@List". I know I can simply use the select statement in the ...
Jonathan Peters's user avatar
0 votes
0 answers
188 views

I need to make changes to database in bulk from information provided on a spreadsheet. At the moment the Table Variable values are added manually, but the hope is to do this automatically from an ...
dori2o's user avatar
  • 31
0 votes
1 answer
2k views

We are planning to create a procedure for our logic what should be in PL SQL in redshift (using workbench). Can we use a table variable to traverse through the rows of the table ? Like we have ...
Shefali Arora's user avatar
0 votes
1 answer
436 views

I have the following plsql block declare TYPE t_mds_ids IS TABLE OF mds.id%TYPE; l_mds_ids t_mds_ids; l_mds_parents t_mds_parents; begin SELECT id BULK COLLECT INTO l_mds_ids FROM ...
MaterialGirl's user avatar
0 votes
1 answer
277 views

I have the following function created with a TVP. I am inserting data initially into the TVP and then selecting from it. CREATE FUNCTION [dbo].employees_data( @employeeIds NVARCHAR(MAX) ) RETURNS ...
Sagar Acharya's user avatar
0 votes
0 answers
269 views

Scenario: user-defined function returns one table. If that table contains at least one row, one column in the table variable from another stored procedure should get updated. Should I use cross join ...
Snehal Sawant's user avatar
0 votes
1 answer
161 views

I've defined a user defined Table type - call it TrackRefsTable Having declared two variables DECLARE @FOO1 AS TrackRefsTable DECLARE @FOO2 AS TrackRefsTable Is there any way to set one to t'other? ...
user avatar
1 vote
1 answer
682 views

When I'm using a table variable to store queried result like this: INSERT INTO @sortedArticleIds SELECT article_id, NULL AS groupBy FROM #articleIds a GROUP BY article_id ORDER BY MIN(...
Chinthaka Fernando's user avatar
-1 votes
1 answer
1k views

I have a stored procedure that returns multiple rows with 5 columns: SELECT Travel, ID, Dept, Role, Country FROM TravelManager For example, I get: DName ID Dept Role Country -----------------...
Jasmine's user avatar
  • 5,317
0 votes
2 answers
877 views

I have a query to first check if something exists. If yes, insert something into a table variable. Otherwise, insert something else into the same table variable. IF NOT EXISTS (SELECT 1 FROM @Main ...
ichachan's user avatar
  • 693
1 vote
1 answer
314 views

I have this scenario: I need to insert the result of many joins (15 tables with various filters) into a table variable var_TB_PROJECT Then insert the result of many other joins (8 tables with various ...
Goldar's user avatar
  • 61
0 votes
1 answer
1k views

I need to create two table-type variables in oracle and make inner join between them. I can't create temporary table in the source database because I dont have privileges. How to create an anonymous ...
Goldar's user avatar
  • 61
1 vote
2 answers
3k views

I'm trying to create a table variable in SQL Server, query it, and return the results to a pandas dataframe (see example). I want to do this so that I can aggregate data in the database prior to ...
user avatar
1 vote
1 answer
4k views

I am using SQL Sever 2016 and I have created user-defined table-type as below: CREATE TYPE [dbo].[UDTT_Items] AS TABLE( [ItemId] int identity(1, 1), [ItemCode] [varchar](10) NULL, [...
M_Idrees's user avatar
  • 2,180
0 votes
2 answers
108 views

I am using SQL Server 2012 and I have the following T-SQL query running against a table on my database. The query runs fine but my issue is that I want to get an output for several specific dates. ...
user3115933's user avatar
  • 4,493
1 vote
3 answers
3k views

I'm trying to write a SP that will allow users to search on multiple name strings, but supports LIKE functionality. For example, the user's input might be a string 'Scorsese, Kaurismaki, Tarkovsky'. ...
Julian Drago's user avatar
1 vote
1 answer
4k views

I would like to create a function in T-SQL which both inputs and outputs instances of a user-defined table type. However, on the line of the RETURN statement, it is throwing an error: Must declare ...
Eric Ma's user avatar
  • 91
0 votes
1 answer
719 views

I'm using DELPHI XE6 with FireDAC components and has a SQL Server database server. In the database, I have a stored procedure that takes two parameters, one integer and then a table variable that ...
larand's user avatar
  • 841
2 votes
3 answers
1k views

Trying to update two tables (City and Location) using two table variables (@NameZip, @NameZip2). The city names have ZipCodes and ZipCodes have Names instead of vice versa. Updates are changing City ...
schikkamksu's user avatar
0 votes
1 answer
585 views

I'm trying to add new rows to the existing tables in the database by using table variables. The problem I'm facing is due to the auto-increment primary key in the database. The tables are like below: ...
schikkamksu's user avatar
0 votes
1 answer
1k views

I have created a memory optimized table type in my database like so: create type tblLocation_InMem as table( IndexLocation int not null index IX_LocInMem, IndexRootLocation int not null, ...
Ian's user avatar
  • 4,487
0 votes
0 answers
116 views

Suppose I have a table variable defined as: DECLARE @FilteredIDs TABLE(ID UNIQUEIDENTIFIER, UNIQUE CLUSTERED (ID)) Functions can return table variables, so supposed I have a function that accepts ...
Triynko's user avatar
  • 19.3k
2 votes
1 answer
247 views

I am working on a query where I need to convert a CSV value holding few ID's sepearated by ,. Currently I am using a Table-Values Function taken from here: SET ANSI_NULLS ON GO SET ...
Cyberpks's user avatar
  • 1,421
-1 votes
1 answer
345 views

In SQL Server, the performance of temp tables is much better (in the means of time) compared to table variables when working with large data (say inserting or updating 100000 rows) (reference: SQL ...
user1080381's user avatar
  • 1,806
0 votes
0 answers
257 views

In Query that haves 3 tables variables joined with 2 tables in some cases where those variable tables are empty (no rows) in the Execution Plan still appears with 16% cost for the scan of each table ...
H.C's user avatar
  • 618
3 votes
3 answers
6k views

How to join 2 table variables which are not consists of a foreign key column. DECLARE @InventoryIDList TABLE(ID INT) DECLARE @ProductSupplierIDList TABLE(ID INT) Excepted output @InventoryList ------...
Harsha W's user avatar
  • 3,386
1 vote
0 answers
121 views

I have a scenario where a Multithreaded .net application calls a stored procedure which in turn uses a temp table in it. In our application concurrently we are calling four threads which ...
Prakash's user avatar
  • 555
0 votes
3 answers
593 views

I'm actually trying to get the data from a table but I wanted that "And/Or" changes based on the table. I'm using SQL Server. I'm into something like this: DECLARE @TURNOS TABLE (ID INT IDENTITY(1,...
Falakienos's user avatar
0 votes
1 answer
352 views

I have a while loop, that will run 300M times. Each time this loop runs, it creates a 1 row table with two columns, which in the end of the loop this table is deleted and once the loop re-starts, ...
wr_lcb_ck's user avatar
1 vote
1 answer
2k views

This question follows from this one. The following SQL works: SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[Update_Repair_Details] @RepairID BIGINT, @NewDetails ...
SezMe's user avatar
  • 537
0 votes
1 answer
3k views

Is it possible to set a variable to have more than one value? In the example below, I would like to set the @variable and use store numbers 1,4,7 and 12 And then use the variable in the WHERE ...
PeterH's user avatar
  • 1,040
0 votes
3 answers
3k views

I have 4 columns in a sql table Offer. id (PK auto increment), name , org , TourCode Varchar(MAX) TourCode contains comma separated codes e.g (AVG123,JGH12 etc ). I have 40000 TourCode available as ...
Ravish Kumar's user avatar
5 votes
1 answer
6k views

My function looks like this: CREATE FUNCTION fn_FileSys_DirExists(@dirName AS nvarchar(260)) RETURNS bit AS BEGIN DECLARE @dirExists int DECLARE @fileResults TABLE ( file_exists ...
ProfK's user avatar
  • 51.4k
0 votes
2 answers
4k views

I have one declared table variable in stored procedure,(sybase database). Data is populated in that table as needed. But now I want to select particular columns based on different conditions. I am ...
Abhijeet_Brbl's user avatar
1 vote
0 answers
396 views

Source table dbo.sourcetable The table has more columns than shown here: | ID | TrackingID | TrackingTime |.... |--------|----------------|-----------------------| | 001 | ...
Phil's user avatar
  • 113