Trying to get the output of all mentioned accounts(total of 9) even though there are no existing records for the GB.periode = 11 Tried using ISNULL(SUM(GB.bdr_val), 0) but still I’m only getting output for GB.reknr = 5210 OR GB.reknr = 5211 OR GB.reknr = 5250 OR GB.reknr = 5340. I have a sample DB layout below, I still need the
Tag: tsql
Executing stored procedure via linked server through trigger
I have created a linked server on a SQL Server connecting to an Azure SQL datawarehouse. When I execute a stored procedure of SQL DW via SSMS as below, it is getting executed as expected. But when I try to have that stored procedure executed as a part of trigger definition And when I try to insert a record into
How to concatenate two different values from two different columns with comma ” , ” using TSQL?
I would like to know how to concatenate two different values from two different columns from a SQL table using TSQL ? As you can see, I would like to concatenate those two different columns X e Y, resulting in the follow column table: Which query should be used here ? Answer You can use concat as
Table get locked when called an SQL Server SP from pyodbc Python [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 months ago. Improve this question Table get locked when called an SQL Server SP from pyodbc Python I have a table I made for testing called test. I just want
SQL Generate per day records between dates
I have a table that where each record has start and end dates. I need to return a record for each day between start and end date fields (including the start and end dates). Using MS SQL Server. Example: Current data Data required: Looking for recommendations. Thanks. Answer You can use recursive cte :
Trigger for INSERT to validate input data in SQL Server?
My problem: table dbo.student has StudentID like SV001. How can I create a trigger to check data inserted into dbo.student has a StudentID that begins with SV and the numbers in the range 000 to 100? Example: SV099 is valid id to insert, while SV101 is not valid Answer Use SQL constraints: Example : Demo in db<>fiddle Or if you
Generate Scripts to move a database from one server to another
I want to move a database from our testing server to my local server. I don’t have the option of back up and restore since I don’t have permission. So I decided to use the generate script option to create all the scripts for the DB and then move over the database to my local server. The problem I’m facing
Select to pull Zip code based both foreign and domestic
I need to write a T-SQL procedure where the parameter is zip code. We’ve got the following parameter declared. Sample data in table: postal_codes NULL 46383 074523632 B4H34 113601419 ZH/8600 A1G 9Z9 WN73R Wd3 3he 89136 etc. We’ve got a variety of addresses some having no postal code for certain foreign countries to some having your standard 5 digit or
Error Referencing Sub Query in Group By on Main Select statement in T-SQL
I am trying to run the following T-SQL code Example: Order table Item table Result: I need to be able to count the number of items for that order per month and year however, I am getting this error Column ‘Order Reference’ is invalid in the select list because it is not contained in either an aggregate function or the
Execute Query Inside Column From CTE
I have a CTE table which returns dynamic SQL. Here is my CTE query: which returns: I want to execute each row on the CTE table. How can I do that? Answer With just a couple of tweaks