SELECT CONVERT([int],11.25)-CONVERT([int],’10.25′) How to avoid error and return 1 as result. >Solution : Rather than using the implicit behaviour of the CONVERT function, why not use the correct function, e.g. ROUND SELECT ROUND(11.25, 0)-ROUND(CONVERT(DECIMAL(9,2),’10.25′), 0)
I have the following SQL query: SELECT D.name, X.displayName, x.diff, X.tacticalParameter_id into kk_aux FROM ( select displayName, tacticalParameter_id, b.value,datediff(DAY,convert(date,b.value,101),convert(date,getdate(),101)) as diff from EDA_TENANT1.EDA_T_P_A A, eda_tenant1.EDA_T_P_A_V b where b.attribute_id = A.ID and displayName like ‘Fecha %’ and value <> ”) X, EDA_TENANT1.EDA_T_P C, EDA_TENANT1.EDA_TACT_P_G D WHERE X.tacticalParameter_id = C.id AND C.tacticalParameterGroup_id = D.id and D.NAME in… Read More Conversion failed when converting date and/or time from character string. SQL query
I’m getting an error when trying to execute the following statements complaining that IDENTITY_INSERT must be on in order for the insert to occur, but I am turning it on. SET IDENTITY_INSERT Thompson_GDM.dbo.employees ON GO INSERT INTO Thompson_GDM.dbo.employees SELECT [EmployeeId], [AssignmentId], [more columns…] FROM TMLAVSQLBIS.ThompsonMachinery.dbo.Employees; GO SET IDENTITY_INSERT Thompson_GDM.dbo.employees OFF go The error message is… Read More I'm having a weird issue with IDENTITY_INSERT & am at a loss. Can anyone see what I'm missing?
How to use Transaction in C# Code On Procedure? >Solution : You can do something like this using ADO .NET: SqlConnection con = new SqlConnection("YOURConnection"); SqlCommand command = new SqlCommand("your procedure",con); con.Open(); // this is a class you can use in order to manage transaction in C# for MS SQL // start scope SqlTransaction trans… Read More Transaction in C# On Procedure
I have a Model containing Propertyes. So, I have a table Models, a Table Properties, and a table ModelProperties (ModelId, PropertyId, Value) Actually when some new Property is/are added (in table Properties), I would like to update the ModelProperties table as well to add the newly added Properties to each of existing Models. See the… Read More SQL : Filter the newly added elements on existing ones
I have a Employee info (one row per employee) table and a Calendar table (one row per day). I want a results table that has one row per day for each employee. employee table EmpID EmpName 0001 Jill 0002 Bill 0003 Steve calendar table Date Month 01/01/2022 January 01/02/2022 January 01/03/2022 January result table Date… Read More Join two dimension tables that don't have a shared key column?
I have a table and I need to insert the data from that table into another blank table in a certain way. Year LoanType ProcessDate Month Balance RowNum TypeRow PercentChange LastCol 2022 0 20220430 04 500 1 1 -1.22 450 2022 0 20220331 03 450 2 2 1.01 200 2022 0 20220228 02 200 3… Read More Insert a column from one table another as a row based on months and years defined in each column
To start, here’s a dummy table I’ve made to show the data I’m working with: employee title division email Boss Person boss o bp@email John Smith supervisor a jos@email Jane Smith supervisor b jas@email Leo Messi employee a lm@email Amanda Kessel employee a ak@email Derek Jeter employee b dj@email I want to end up with… Read More SQL join manager from same table onto a row with their employees
I have a column where it stores a reference the reference is usually 30 alphanumeric values The column is set as an nvarchar (30). Id like to update this to nvarchar (5), and update all the values currently stored in this column.. is there a way to do this using update? >Solution : First update… Read More Column update – SQL UPDATE statement
I am wondering if there is any way to save the intermediate result or tables in SQL. For example assume you have two different SQL statements that in the first statement you join two tables, then you want to see how many rows the resulting table has. I know there are many ways to do… Read More Save the intermediate result of SQL query