블로그 이미지
bedbmsguru

Notice

Recent Post

Recent Comment

Recent Trackback

Archive

calendar

1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
  • total
  • today
  • yesterday
2020. 3. 25. 10:22 SQL SERVER

SELECT f.name, OBJECT_NAME(f.parent_object_id) TableName, COL_NAME(fc.parent_object_id,fc.parent_column_id) ColName

FROM sys.foreign_keys AS f

INNER JOIN sys.foreign_key_columns AS fc

    ON f.OBJECT_ID = fc.constraint_object_id

INNER JOIN sys.tables t

    ON t.OBJECT_ID = fc.referenced_object_id

WHERE OBJECT_NAME (f.referenced_object_id) = '테이블명'

출처: https://hackhyun.tistory.com/250 [전산이야기]

'SQL SERVER' 카테고리의 다른 글

Extended Event Data Table 로 가져오기  (0) 2020.10.13
SQL Formatter  (0) 2020.06.05
sql server 2012 Recommended Trace flag  (0) 2020.02.13
Oracle Client 업그레이드  (0) 2020.01.16
sql server default 제약조건 조회SQL  (0) 2020.01.15
posted by bedbmsguru
2020. 2. 13. 16:29 SQL SERVER

-T272

-T1118

-T2371

-T3226

-T3449

 

-T272 SQL Server 재시작시 identity 옵션의 이상증가 현상을 방지

-T1118 SGAM 할당 경합을 막기위해 혼합익스텐트를 사용하지 않고 균일익스텐트만 사용한다.

    단점: SGAM경합은 개선되지만 최소 할당크기가 64KB가 되기때문에 공간의 낭비가 발생

-T2371: 통계 업데이트시 테이블크기에 맞춰 샘플데이터를 추출한다. (큰 테이블은 적은비율, 작은 테이블은 높은비율)

-T3226: 성공한 백업기록은 ErrorLog에 기록하지 않는다.

-T3449: 아래의 작업들의 성능을 개선한다.

            backup database, backup transaction log, create database, add a file to a database,

            restore a transaction log, recover a database, shrink a database file, and a SQL Server "graceful" shutdown 

        !! T3449 옵션은 2012 SP Cu3이상이거나 2014 SP1 CU7 이상에서만 ON 해야 한다.

 

--상태확인

DBCC TRACESTATUS(-1)

 

https://www.alexvolok.com/2018/helpful-trace-flags-sql-server/

posted by bedbmsguru
2020. 1. 16. 09:10 SQL SERVER

1. tnsname.ora 백업

--> 오라클Client 설치폴더\product\18.0.0\client_1\network\admin

 

2. SQL Server Stop

--> SQL Server 가 실행중인 상태에서는 이미 오라클Client가 사용중이기 때문에 제대로 제거가 되지 않는다.

 

3. 설치된 오라클Client 제거

--> CMD실행 

--> 폴더 이동을 하지 않고 절대경로를 타이핑 해서 실행할 것(나중에 폴더가 깔끔하게 지워지게 하기위해)

     D:\>d:\오라클Client 설치폴더\product\18.0.0\client_1\deinstall\deinstall.bat

 

4. 신규 오라클Client 설치

  -->관리자 옵션으로 설치 (그렇게 해야 deinstall이 생겨 추후 제거가 쉽다.)

 

5.백업한 tnsname.ora Copy

--> 오라클Client 설치폴더\product\18.0.0\client_1\network\admin

--> 파일 복사를 하기전에 SQL Server를 시작하면 오라클Client가 정상작동 되지 않음

 

6. SQL Server Start 후 오라클Client InProcess 허용 체크

--> SSMS실행 --> 서버개체--> 연결된서버 --> 공급자--> OraOLEDB.Oracle 마우스오른쪽버튼 --> 속성 --> Inprocess허용 체크(이전버전에서 체크해 두었을경우 이미체크되어 있음)

 

7. 오라클 LinkedServer 작동여부 확인

--> 업그레이드 확인: SELECT * FROM sys.dm_os_loaded_modules WHERE company='Oracle Corporation'

--> SELECT * FROM OPENQUERY(링크이름, 'SELECT 1 FROM DUAL')

posted by bedbmsguru
2020. 1. 15. 16:36 SQL SERVER

DB의 default Constraint 가져오기

 

select con.[name] as constraint_name, schema_name(t.schema_id) + '.' + t.[name] as [table],

col.[name] as column_name,

con.[definition]

from sys.default_constraints con

left outer join sys.objects t

on con.parent_object_id = t.object_id

left outer join sys.all_columns col

on con.parent_column_id = col.column_id

and con.parent_object_id = col.object_id order by con.name

 

출처

https://dataedo.com/kb/query/sql-server/list-all-default-constraints-in-the-database

'SQL SERVER' 카테고리의 다른 글

sql server 2012 Recommended Trace flag  (0) 2020.02.13
Oracle Client 업그레이드  (0) 2020.01.16
SQL SERVER Setup 실행시 오류발생 해결  (0) 2019.12.26
Table Size 확인 쿼리  (0) 2019.12.12
테이블 반환 함수  (0) 2019.10.25
posted by bedbmsguru
2019. 12. 26. 10:26 SQL SERVER

출처: https://goosl.tistory.com/entry/MS-SQL-설치-센터-실행시-오류 [하늘 빛 하늘]

 

[MS-SQL] 설치 센터 실행시 오류

MS-SQL을 삭제후 다시 설치를 위해 MS-SQL 2008 setup.exe 파일을 오픈 했을 때 다음과 같은 오류가 떴다. 오 마이갓... 캡쳐를 앞 부분이 짤리게 했다 ㅠㅠ 자세히 보면. 내용은 다음과 같다 System.Configurati..

goosl.tistory.com

설치를 위해서 Setup을 실행할경우 아래 오류가 발생하는 경우가 있다.

 

solution
해결 방법은 저기 보이는 디렉토리 폴더를 삭제 해주면 된다. 


 

System.Configuration.ConfigurationErrorsException: An error occurred creating the configuration section handler for userSettings/Microsoft.SqlServer.Configuration.LandingPage.Properties.Settings: Could not load file or assembly ‘System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′ or one of its dependencies. The system cannot find the file specified. (C:\Users\Administrator\AppData\Local\Microsoft_Corporation\LandingPage.exe_StrongName_ryspccglaxmt4nhllj5z3thycltsvyyx\10.0.0.0\user.config line 5) —> System.IO.FileNotFoundException: Could not load file or assembly ‘System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′ or one of its dependencies. The system cannot find the file specified.
File name: ‘System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′
at System.Configuration.TypeUtil.GetTypeWithReflectionPermission(IInternalConfigHost host, String typeString, Boolean throwOnError)
at System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.Init(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord)
at System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.InitWithRestrictedPermissions(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord)
at System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory..ctor(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord)
at System.Configuration.RuntimeConfigurationRecord.CreateSectionFactory(FactoryRecord factoryRecord)
at System.Configuration.BaseConfigurationRecord.FindAndEnsureFactoryRecord(String configKey, Boolean& isRootDeclaredHere)

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].



출처: https://goosl.tistory.com/entry/MS-SQL-설치-센터-실행시-오류 [하늘 빛 하늘]

 

 

'SQL SERVER' 카테고리의 다른 글

Oracle Client 업그레이드  (0) 2020.01.16
sql server default 제약조건 조회SQL  (0) 2020.01.15
Table Size 확인 쿼리  (0) 2019.12.12
테이블 반환 함수  (0) 2019.10.25
DB파일 MDF 사용량 SIZE 확인  (0) 2019.10.21
posted by bedbmsguru
2019. 12. 12. 11:11 SQL SERVER

SELECT      t.NAME AS TableName
,    s.Name AS SchemaName
,    p.rows
,      CAST(ROUND(((SUM(a.total_pages)   *  8)   /  1024.00),  2)  AS NUMERIC(36,  2))  AS TotalSpaceMB
,      CAST(ROUND(((SUM(a.total_pages)   *  8)   /  1024.00/1024),  2)  AS NUMERIC(36,  2))  AS TotalSpaceGB
,      CAST(ROUND(((SUM(a.used_pages)   *  8)   /  1024.00),  2)  AS NUMERIC(36,  2))  AS UsedSpaceMB
,      CAST(ROUND(((SUM(a.used_pages)   *  8)   /  1024.00/1024),  2)  AS NUMERIC(36,  2))  AS UsedSpaceGB
,    CAST(ROUND(((SUM(a.total_pages)   -  SUM(a.used_pages))   *  8)   /  1024.00,  2)  AS NUMERIC(36,  2))  AS UnusedSpaceMB FROM      sys.tables t INNER JOIN           sys.indexes i ON t.OBJECT_ID  =  i.object_id INNER JOIN      sys.partitions p ON i.object_id  =  p.OBJECT_ID AND i.index_id  =  p.index_id INNER JOIN       sys.allocation_units a ON p.partition_id  =  a.container_id LEFT OUTER JOIN      sys.schemas s ON t.schema_id  =  s.schema_id WHERE      t.NAME NOT LIKE  'dt%'       AND t.is_ms_shipped  =  0     AND i.OBJECT_ID  >  255  GROUP BY      t.Name
, s.Name
, p.Rows ORDER BY      TotalSpaceMB DESC
, t.Name

 

https://stackoverflow.com/questions/7892334/get-size-of-all-tables-in-database/7892349

'SQL SERVER' 카테고리의 다른 글

sql server default 제약조건 조회SQL  (0) 2020.01.15
SQL SERVER Setup 실행시 오류발생 해결  (0) 2019.12.26
테이블 반환 함수  (0) 2019.10.25
DB파일 MDF 사용량 SIZE 확인  (0) 2019.10.21
available threads 갯수 구하기  (0) 2019.10.17
posted by bedbmsguru
2019. 10. 25. 13:59 SQL SERVER

테이블 반환함수 VIEW를 대체하면 VIEW보다 성능이 좋다.

 

 

https://templar.tistory.com/34

posted by bedbmsguru
2019. 10. 21. 10:59 SQL SERVER

SELECT

       DB_NAME() AS 'DB '

       ,d.name AS '파일그룹명'

       ,e.tSize AS '전체사이즈(mb)'

       ,SUM(used_page_count)*8 /1024.0 AS '현재사이즈(mb)'

       ,e.tSize-SUM(used_page_count)*8 /1024.0 AS '남은사이즈(mb)'

       ,cast((SUM(used_page_count)*8/1024.0)*100/e.tSize AS DECIMAL(10,2))AS '사용량(%)'

FROM sys.objects AS a  JOIN sys.dm_db_partitiON_stats AS b

ON a.object_id = b.object_id

JOIN  sys.sysindexes AS c

ON a.object_id = c.id

AND b.index_id = c.indid

JOIN sys.filegroups AS d

ON c.groupid = d.data_space_id

JOIN (SELECT data_space_id,SUM(size)*8/1024.0 AS 'tSize'

             FROM sys.databASe_files WHERE data_space_id <> 0 GROUP BY data_space_id) AS e

ON d.data_space_id = e.data_space_id        

GROUP BY d.name,c.groupid,e.tSize



출처: https://sqltalk.tistory.com/15 [SQLTalk]

posted by bedbmsguru
2019. 10. 17. 15:03 SQL SERVER

declare @max int
select @max = max_workers_count from sys.dm_os_sys_info

select 
    @max as 'TotalThreads',
    sum(active_Workers_count) as 'CurrentThreads',
    @max - sum(active_Workers_count) as 'AvailableThreads',
    sum(runnable_tasks_count) as 'WorkersWaitingForCpu',
    sum(work_queue_count) as 'RequestWaitingForThreads' ,
    sum(current_workers_count) as 'AssociatedWorkers'
from  
    sys.dm_os_Schedulers where status='VISIBLE ONLINE'

 

 

https://dba.stackexchange.com/questions/188102/who-is-using-my-worker-threads-sql-server-2014-hadr

 

posted by bedbmsguru
2019. 10. 1. 15:41 SQL SERVER

DECLARE @dateval DATETIME

 

EXECUTE ('begin my1.spGetDate(?); end;', @dateval OUTPUT) AT ORA_DBLINK_NAME;

 

EXECUTE ('begin my1.spDeleteOldRecords(?); end;', @dateval) AT ORA_DBLINK_NAME;

 

--파라미터 여러개

EXECUTE ('begin my1.spProc(?,?,?,?); end;', @param_in_1, @param_in_2, @param_out_3 OUTPUT, @param_out_4 OUTPUT) AT DBLINK_NAME;

 

 

출처

https://stackoverflow.com/questions/13741175/calling-oracle-stored-procedure-with-output-parameter-from-sql-server

posted by bedbmsguru