Posts

Showing posts with the label tsql

T-sql subscript only numbers from string, cannot use create procedure, create table, etc

Image
Clash Royale CLAN TAG #URR8PPP T-sql subscript only numbers from string, cannot use create procedure, create table, etc Similar questions have been posted in the past, but I work in a very limited environment. The offered solutions involved using create procedure, create table, etc. None of that is available here. How can I subscript only digits (0-9) that are non-continuous from strings such as '09text10more text!@@#11' to return 091011?. Is it possible with a combination of functions, something like SELECT Funtion1(Function2(StringField)) From Schema.Table?. Data type is varchar(30). Thank you. So, you need to be able to execute this within the context of a single query? – csharplova yesterday Please read this for some tips on improving your question. It's helpful to tag database questions wit...

Produce data extracts using day field for the Friday before the weekend

Image
Clash Royale CLAN TAG #URR8PPP Produce data extracts using day field for the Friday before the weekend Using TSQL on SQL Server... I need to produce extracts that use a pay day column in a database that only holds the day number, for example 26 to produce extracts for the 26th day of the month with a twist if that pay day falls on a weekend then the data for that extract should be extracted the Friday before the weekend. Has anybody attempted this and able to offer some ways of achieving this through TSQL? Thanks Are you always running this for the current month? Otherwise I cannot see how any logic is expected to guess what month you are running it for. – MandyShaw 14 hours ago 1 Answer 1 I'm assuming you have the month and year available too, in wh...

Print Max query in sql

Image
Clash Royale CLAN TAG #URR8PPP Print Max query in sql How to print dynamic query that contains more than 8000 chars. Declare @sql varchar(max) set @Qry='....(more than 8000 char)' Print (@Qry) Any help? Thanks. Print (CAST(@Qry as TEXT)) – Tapakah Ua 10 mins ago varchar(max) can store up to 2gb .... – JeffUK 7 mins ago 1 Answer 1 Just do it, varchar(max) can hold upto 2gb. E.g. declare @test varchar(max); declare @loop int = 1; set @test= 'select ''1000000000000000000000000000000000000000000'''; while @loop < 1001 begin set @test = @test + ',''1000000000000...

Insert one row foreach column value

Image
Clash Royale CLAN TAG #URR8PPP Insert one row foreach column value I'm new in sql. I have table like this: +-----------+-------+ | DesignKey | Order | +-----------+-------+ | 1461 | 10 | | 1461 | 12 | | 1461 | 9 | | 1461 | 6 | | 1461 | 5 | | 1461 | 4 | | 1461 | 3 | | 1461 | 13 | | 1461 | 1 | +-----------+-------+ As you can see I have one DesignKey with the same number foreach Order number. My table have alot of DesignKey numbers but each one have Order from 1 to 13. DesignKey Now I added other Order Number to 14. That I want to do is foreach DesignKey create anoter row with order 14. How can I achieve that? Regards By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.