I have a stored procedure which inserts my data into the table after selecting data from…
Private research annotation
Sign in to add a private research label or note.
- User
I have a stored procedure which inserts my data into the table after selecting data from top subqueries. But the order by clause after select doesn't work, when i look at the data in my inserted table. Here is the end part of the code of my stored procedure:- INSERT INTO [curated].[dbo].[M107_Flat_File] (Unique_Key, Barcode, Start_Datetime, Recipe, Batch_ID, Mixing_Time, Cycle_Time, BWB_Time, CT_Sec_Incremental, MixEnergy_Sec_Incremental, MixPower_Sec_Incremental, MixPressure_Sec_Incremental, MixSpeed_Sec_Incremental, MixTemp_Sec_Incremental, Batch_Total_Energy, Alarms)
codeSelectCAST(CASE WHEN Y.Unique_Key_Y IS NULL tHEN mix_term_act_merge.Unique_Key_mix_term_act_merge ELSE Y.Unique_Key_Y end as bigint) as Unique_Key, CAST(X.Barcode as bigint) as Barcode, CAST(X.start_datetime as datetime) as start_datetime , CAST(X.Recipe as varchar(25)) as Recipe, CAST(X.Batch_ID as INT) as Batch_ID , CAST(X.Mixing_Time as INT) as Mixing_Time, CAST(X.Cycle_Time as INT) as Cycle_Time, CAST(X.BWB_Time as INT) as BWB_Time, Cast(y.CT_Sec_Incremental as decimal(10,2)) as CT_Sec_Incremental, CAST(Y.MixEnergy_Sec_Incremental as decimal(10,2)) as MixEnergy_Sec_Incremental, CAST(Y.MixPower_Sec_Incremental as decimal(10,2)) as MixPower_Sec_Incremental, CAST(Y.MixPressure_Sec_Incremental as decimal(10,2)) as MixPressure_Sec_Incremental, CAST(Y.MixSpeed_Sec_Incremental as decimal(10,2)) as MixSpeed_Sec_Incremental, CAST(Y.MixTemp_Sec_Incremental as decimal(10,2)) as MixTemp_Sec_Incremental, CAST(X.Batch_Total_Energy as decimal(10,2)) as Batch_Total_Energy, CAST(X.Alarms as varchar(max)) as Alarms
codefrom x left join y on X.Barcode = Y.Barcode full outer join mix_term_act_merge on Y.Unique_Key_Y = mix_term_act_merge.Unique_Key_mix_term_act_mergeand mix_term_act_merge.MixTime = Y.MixtimeX ORDER BY Y.Unique_Key_Y asc, X.Start_datetime asc
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.