I have a list of ids that i need to loop through, and use in an insert statement for example I have built the table here: DECLARE @ProductIds TABLE (ID nvarchar(1000)) INSERT INTO @ProductIds (ID) SELECT ProductTypeId FROM ProductType DECLARE MY_CURSOR ...
databaseanswers.net Latest Questions
The table in the database is defined by catalog_name.schema_name.table_name. The following query: SELECT schema_name(schema_id) schema_name, name object_name, type, type_desc FROM sys.system_views UNION ALL SELECT schema_name(schema_id) schema_name, ...
I have tables three tables: #T, #T1, #Maintable, for which I’ll attach the corresponding DDL. Create table #T ( id int , reason varchar (50)); insert into #T Values (1,'Texas for live music'); insert into #T Values (1,'Texas ...
I have a table with accounts and payment type. Every account MUST have 1 payment type of ‘GOGW’, 1 account may have multiple payment types. I need to find a way to identify which accounts don’t have a ‘GOGW’ please table1
I have a table like this: CREATE TABLE WeeklySlots ([dow] int, [slots] int, [SlotCode] varchar(6)) ; INSERT INTO WeeklySlots ([dow], [slots], [slotCode]) VALUES (1, 0, 'T19_00'), (2, 20, ...
I am new to sql, so i need some help with query generation I have two sql queries, first: SELECT COUNT([Mark]) AS MCount, [crpt].[dbo].[Products].Name FROM ...
Please find the SQL followed to generate new seq number CREAT PROCEDURE [dbo].[axsp_get_next_no_internal_64] @table_name nvarchar(30), @increment int = 1, @log_id ...
Updated in response to comments. I have a table that consists of a record ID, a group ID (linking 1 or more records into a group) and a hash value for each record. CREATE TABLE HashTable( RecordID VARCHAR(255), ...
Now, I have a pivoted query that will bring a set of events that took place on all the towns registered in a table and a date range. This is my query: DECLARE @cols AS NVARCHAR(MAX), @query AS NVARCHAR(MAX) CREATE TABLE #tempDates ( ...
I’m trying to return the most recent record grouped on a specific ID, but I need to return the unique identifier (change_guid) from each returned record so that I can use it later. Using the below correctly returns 28,908 records: SELECT account_id, ...