This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IF(OBJECT_ID('tempdb..#MapTable') IS NOT NULL) | |
DROP TABLE #MapTable | |
-- | |
DECLARE @t1 TABLE (n1 VARCHAR(5)) | |
DECLARE @t2 TABLE (n2 INT) | |
DECLARE @t3 TABLE (n3 INT) | |
INSERT into @t1 VALUES ('4.1.1'), ('4.1.2'), ('4.2.1'), ('4.2.2'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE PROCEDURE dbo.notnullcolumns | |
@t varchar(128) | |
AS | |
BEGIN | |
declare | |
@c_name varchar(300), | |
@sql varchar(max) | |
declare c cursor for |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE FUNCTION [dbo].[FOMONTH] (@d date) | |
returns date | |
AS | |
Begin | |
DECLARE @sd DATE | |
SET @sd = DATEADD(month, DATEDIFF(month, 0, @d ), 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1) numbers from 1 to 10 | |
SELECT LEVEL FROM dual CONNECT BY LEVEL <= 10; | |
WITH numbers(n) | |
AS ( | |
SELECT 1 | |
UNION ALL | |
SELECT n + 1 FROM numbers | |
WHERE n+1 <= 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0) run for see result: | |
SELECT regexp_substr(regexp_replace('&STRING', '[^A-Z0-9-,]', ''), | |
'[^,]+', | |
1, | |
LEVEL) a | |
FROM dual | |
CONNECT BY regexp_substr(regexp_replace('&STRING', '[^A-Z0-9-,]', ''), | |
'[^,]+', | |
1, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import pandas as pd | |
from datetime import date | |
f_name = 'Samle Data.xlsx' # Enter excel file name (from the same directory) | |
prfx = os.path.splitext(f_name)[0] # you can change prefix | |
sffx = datetime.today().strftime('%Y-%m-%d') # or suffix | |
WS = pd.ExcelFile(f_name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE PROCEDURE NOTNA_ROWS --get not null rows | |
@t varchar(128) --your table name | |
AS | |
BEGIN | |
declare | |
@c_name varchar(128), | |
@sql varchar(max) | |
declare c cursor for |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;WITH CTE AS ( | |
SELECT 1 as Number | |
UNION ALL | |
SELECT Number+1 | |
FROM CTE | |
WHERE Number < 100 | |
) | |
SELECT RAND(CHECKSUM(NEWID() )) AS randnumber FROM CTE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;WITH CTEearthquakes as ( | |
SELECT | |
earthquakes.cDate, | |
earthquakes.Magnitude | |
FROM ( | |
VALUES | |
('1/5/2007', 5.8), | |
('1/1/2008', 5.6), |