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
Tag: sql-server
How to add split between duplicate value in SQL
I have SQL Server table that have duplicated value in field and need to split by slash character. All field start with alphabetical char end with ‘M’ char For example: and need to convert to: Thanks Answer Probably many ways to skin this cat, assuming you’re always looking for the same initial character repeated within the string, the following uses
OLE DB Destination: Invalid character value for cast specification
My table source: num_facture TYPE actif date 1 1 1 2010-01-31 00:00:00.000 2 2 1 2011-01-31 00:00:00.000 3 3 2 2012-01-31 00:00:00.000 4 4 2 2013-01-31 00:00:00.000 The Column data types are: Column Data Type TYPE tinyint Actif tinyint date datetime I’m working with SSIS to load my destination table. So, I want to change TYPE for Normal if 1
SQL Server – Concatenate – Stuff doesn’t work
I have this query in SQL Server and I want to concatenate using stuff the ‘Products’ column, but I don’t know why this doesn’t work… And the result is: And I want this: Also I used SELECT DISTINCT in the query but the result is the same… So, where can be the mistake? Answer SQL Server 2017 and Later Versions
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
How find last number of sequence numbers in sql?
I want find last number of sequence in sql query for fill automatically suggestion field value. forexample my code field(column) is :1,2,3,4,10,20 so i want found 4 in my query Answer If your table is called table_name and looks like this: id 1 2 3 4 10 20 Then this should work: Fiddle
How to pass a list of strings as a parameter in a stored procedure in SQL?
How to pass a list of strings as a parameter in a stored procedure in SQL? Like for example if I have a stored procedure proc_aggregation that takes two parameters @Prod_Desc of varchar data type and another parameter @Prod_Code as a list of strings (Eg : @Prod_Code = (‘12012’, ‘12011’, ‘12014’)). Answer You will have to use table valued parameters
Calculate rank based on Consecutive Dates (Return to 1 if there is a gap days between dates)
I am trying to get the rank column of this table. Key Date1 Name1 Location1 20 2021-12-30 Ann Site A 23 2021-12-31 Ann Site A 26 2022-01-03 Ann Site A 28 2022-01-04 Ann Site A 29 2022-01-05 Ann Site A 32 2022-01-06 Ann Site A 62 2022-01-08 Ann Site A 63 2022-01-10 Ann Site A 64 2022-01-11 Ann Site A
Is there a way to use IN and it evaluate values left to right in T-SQL?
Simplified example: I have been searching and cannot find a solid answer on this. I want to use the IN clause to get certain rows, but I want it to work left to right. In the example above, I would want a row for 2021, then 2015, then 2010 (assuming no seasons were null). Is there a way to make
How to dynamically write OR clause in Contains query?
Is there a way to generate the second part of this SQL query (OR clauses) from a string split? String split values come from : Answer You can split the string using STRING_SPLIT(), then rebuild it using STRING_AGG(), and simply pass the resulting string into CONTAINS: Or even simpler: In both cases, @SearchPhrase looks like this: