Skip to content

How to extract numbers from a string SQL

Ts there a way to extract numbers from a string? In my database there is a column called Reference and it contains multiple numbers CM|319|14163|||109|405000 Is there a way to get the first number like this? select CM|%s|… as ParentId from table So the output should be 319 And maybe even multiple like s…

Trigger to create or update records in another table

Edit: This question is mostly solved. What I am still trying to do might require a different approach. I am adding a trigger to a legacy database table, in order to automatically create new records for a related table. This is not homework. Here is my DB Fiddle on SQL Server 2017. https://dbfiddle.uk/?rdbms=s…

How do I show all records when one field is null in SQL?

I have my code but the @NAME is an optional field for searching. If the @NAME is blank or NULL, it should show all records. How do I approach this? Thanks! Answer There are some ways to do it the easy way. I would do something like this. You can use the Function ISNULL to handle blank or NULL. With

Trying find a better writing for my SQL Query [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 last year. Improve this question I Have a database of published website pages, with following coulmns: date| publisher_id | pla…