'DB/MSSQL'에 해당되는 글 12건

페이지 쿼리

DB/MSSQL 2019. 3. 22. 11:41

페이지 쿼리


SELECT

ct_idx, 

ct_class, dbo.GET_CODENAME('CTC',ct_class) as ct_classToKr , 

ct_setFlag, dbo.GET_CODENAME('CTS',ct_setFlag) as ct_setFlagToKr, 

ct_bidFlag, dbo.GET_CODENAME('CTB',ct_bidFlag) as ct_bidFlagToKr, 

ct_title, ct_dept_no, ct_dept_name, isused, 

hit, convert(varchar(10),join_date,121) as join_date

FROM TBE_CONTRACT where ct_idx in  (

SELECT 

TOP $ent.rowSize 

ct_idx

FROM (

SELECT 

TOP $ent.currentSize

ct_idx, $ent.orderBy

FROM 

TBE_CONTRACT

WHERE 

1=1

AND pid = $ent.pid

#if($ent.used != "")

AND isused = $ent.used

#end

#if($ent.isdel != "")

AND isdel = $ent.isdel

#end

#if($ent.funcII != "")

AND ct_dept_no in(select ucode from dbo.GET_SUBDEPTCODE(#$ent.funcII::#))

#end

#if($ent.rsType != "" && $ent.rsKey!="")

AND $ent.rsType LIKE '%$ent.rsKey%'

#end

#if($ent.startDate != "" && $ent.endDate != "")

and left(join_date,10) between #$ent.startDate::# and #$ent.endDate::#

#end

and left(join_date,10)>=convert(varchar(4),dateadd(year, -2, getdate()),121)+'-01-01'

ORDER BY 

$ent.orderBy $ent.cendingBy , 

ct_idx $ent.cendingBy

) scan

ORDER BY 

scan.$ent.orderBy $ent.cendingIn , 

scan.ct_idx $ent.cendingIn 

)

            ORDER BY 

                $ent.orderBy $ent.cendingBy , 

ct_idx $ent.cendingBy


'DB > MSSQL' 카테고리의 다른 글

dblink3  (0) 2019.04.02
dblink  (0) 2019.04.02
dblink2  (0) 2019.03.22
페이지 쿼리2  (0) 2019.03.22
DBLINK  (0) 2019.03.21
블로그 이미지

마크제이콥스

초보 개발자의 이슈및 공부 내용 정리 블로그 입니다.

,

DBLINK

DB/MSSQL 2019. 3. 21. 17:11

DBLINK




1. sa 계정으로 sql 스튜디오에 접속한다.


2. 원격 DB링크 연결

-> exec sp_addlinkedserver @server='생성할디비링크명', @srvproduct='', @provider='SQLOLEDB', @datasrc='접속할디비아이피'


3. 원격 DB에 로그인 허용

-> exec sp_addlinkedsrvlogin @rmtsrvname='DB 링크명', @useself='False', @locallogin=Null, @rmtuser='계정명', @rmtpassword='비밀번호';


4. 원격 DB의 프로시져 호출

-> exec 링크명.데이터베이스명.계정명.프로시저명;


5. 만약 RPC에 대해 구성되지 않았습니다 라는 오류가 뜬다면 아래 설정을 바꿔준다.


연결된서버로부터 로컬서버로의 RPC 호출을 활성화

EXEC sp_serveroption 'DB 링크명', 'rpc', TRUE;


6. 로컬서버로부터 연결된서버로의 RPC 호출을 활성화

EXEC sp_serveroption 'DB 링크명', 'rpc out', TRUE;

'DB > MSSQL' 카테고리의 다른 글

dblink3  (0) 2019.04.02
dblink  (0) 2019.04.02
dblink2  (0) 2019.03.22
페이지 쿼리2  (0) 2019.03.22
페이지 쿼리  (0) 2019.03.22
블로그 이미지

마크제이콥스

초보 개발자의 이슈및 공부 내용 정리 블로그 입니다.

,