temp-tables

SQL FUNCTION LIKE SEARCH ISSUE

随声附和 提交于 2020-01-16 19:43:37
问题 please help to fix my sql function! in my sql function i have one temporary tables parameter passing to function @searchstring ---- "'%carrots%' AND tmp.ItemDescription like '%baby%'" Declare @tempvalues table (itemdescription nvarchar(max)) @tempvalues VALUES ----------------------- CARROTS, BABY, CLASS I, FRESH CARROTS, BABY, FROZEN CARROTS, CLASS I, FRESH ------------------ so in function iam passing value for searching data using like query and if matches i need to insert data in another

Having issues creating a temporary table out of a UNION

我怕爱的太早我们不能终老 提交于 2020-01-14 09:58:26
问题 I have a UNION statement that executes just fine by itself: SELECT "1999999999" AS MobileNo, "Test" AS FirstName, "Last" AS LastName, "268" AS TemplateID, "" AS MISC1, "" AS MISC2 UNION SELECT cust.cellp AS MobileNo, acct.firstname AS FirstName, acct.lastname AS LastName, "268" AS TemplateID, "" AS MISC1, "" AS MISC2 FROM acct INNER JOIN cust ON (cust.socsec=acct.socsec) However when I try to wrap it with a CREATE TEMPORARY TABLE: CREATE TEMPORARY TABLE temptable (SELECT "1999999999" AS

How can I store the output of a query into a temporary table and use the table in a new query?

江枫思渺然 提交于 2020-01-13 05:00:28
问题 I have a MySQL query which uses 3 tables with 2 inner joins. Then, I have to find the maximum of a group from this query output. Combining them both is beyond me. Can I break down the problem by storing the output of the first complicated query into some sort of temporary table, give it a name and then use this table in a new query? This will make the code more manageable. Thank you for your help. 回答1: This is very straightforward: CREATE TEMPORARY TABLE tempname AS ( SELECT whatever,

Child sProc cannot reference a Local temp table created in parent sProc

ぃ、小莉子 提交于 2020-01-06 02:04:06
问题 On our production SQL2000 instance, we have a database with hundreds of stored procedures, many of which use a technique of creating a #TEMP table "early" on in the code and then various inner stored procedures get EXECUTEd by this parent sProc. In SQL2000, the inner or "child" sProc have no problem INSERTing into #TEMP or SELECTing data from #TEMP. In short, I assume they can all refer to this #TEMP because they use the same connection. In testing with SQL2008, I find 2 manifestations of

PostgreSQL dump Temp table

做~自己de王妃 提交于 2020-01-05 14:06:14
问题 I created a temp table in my PostgreSQL DB using the following query SELECT * INTO TEMP TABLE tempdata FROM data WHERE id=2004; Now I want to create a backup of this temp table tempdata . So i use the following command line execution "C:\Program Files\PostgreSQL\9.0\bin\pg_dump.exe" -F t -a -U my_admin -t tempdata myDB >"e:\mydump.backup" I get a message saying pg_dump: No matching tables were found Is it possible to create a dump of temp tables ? Am I doing it correctly? P.S. : I would also

PostgreSQL dump Temp table

天大地大妈咪最大 提交于 2020-01-05 14:05:32
问题 I created a temp table in my PostgreSQL DB using the following query SELECT * INTO TEMP TABLE tempdata FROM data WHERE id=2004; Now I want to create a backup of this temp table tempdata . So i use the following command line execution "C:\Program Files\PostgreSQL\9.0\bin\pg_dump.exe" -F t -a -U my_admin -t tempdata myDB >"e:\mydump.backup" I get a message saying pg_dump: No matching tables were found Is it possible to create a dump of temp tables ? Am I doing it correctly? P.S. : I would also

Sql server - how to insert single row into temporary table?

家住魔仙堡 提交于 2020-01-05 03:36:26
问题 I have two temporary table, when i do cycle through one table and i get some values from it, in this cycle I need insert new row into another temporary table. Is this possible. Here is my sql code and error information: Alter PROCEDURE ProfitReportQ_Search_WithSub (@DateFrom datetime, @DateTo datetime, @DateActive bit, @UserID int, @ItemGroupIDValues nvarchar(max) ) AS BEGIN CREATE TABLE #tmp(ItemGroupID int, ItemGroupName nvarchar(250), Manager nvarchar(250), AllQuantity int, AllSumPrice

Cannot find user defined datatype 'empnum' in SQL Server 2014

别说谁变了你拦得住时间么 提交于 2020-01-04 02:57:08
问题 When I run the following query in SQL Server 2014 to create a temporary table: CREATE TABLE #temp ( location char(16) null, location_desc varchar(25) null, Emp_Num EMPNUM null ) I receive the error: Cannot find the data type empnum. empnum is a user-defined data type. But the same user-defined data type is working fine in other stored procedures. Why am I receiving this error? 回答1: It looks like user defined types are defined at database level , not instance level , so they must be defined

Join the same table temporary table in MySQL

守給你的承諾、 提交于 2020-01-03 17:48:27
问题 I like to join a temporary table in MySQL which fails, the idea quite simple: CREATE TEMPORARY TABLE temp_table LIKE any_other_table; -- srsly it does not matter which table ( SELECT p1,p2,p3 FROM temp_table WHERE p4 = 1 ) UNION ( SELECT p1,p2,p3 FROM temp_table WHERE p4 = 2 ) Any help is greatly appreciated. EDIT: The error thrown by mysql is ERROR 1137 (HY000): Can't reopen table: 'temp_table' 回答1: You cannot refer to a TEMPORARY table more than once in the same query. Please read the

Join the same table temporary table in MySQL

给你一囗甜甜゛ 提交于 2020-01-03 17:48:14
问题 I like to join a temporary table in MySQL which fails, the idea quite simple: CREATE TEMPORARY TABLE temp_table LIKE any_other_table; -- srsly it does not matter which table ( SELECT p1,p2,p3 FROM temp_table WHERE p4 = 1 ) UNION ( SELECT p1,p2,p3 FROM temp_table WHERE p4 = 2 ) Any help is greatly appreciated. EDIT: The error thrown by mysql is ERROR 1137 (HY000): Can't reopen table: 'temp_table' 回答1: You cannot refer to a TEMPORARY table more than once in the same query. Please read the