'SP'에 해당되는 글 2건

  1. 2010.11.01 C# ms-sql SP output 값 받아오는 예제 1
  2. 2010.10.18 OPENXML(MS-SQL SP) 1


public string UserInfo(string strUserID, string strPassword)
        {
            string result_value = string.Empty;
            try
            {
                dbConn = new SqlConnection(strConnectionString);
               

                SqlCommand cmd = new SqlCommand();
                cmd.Connection = dbConn;
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "RF_0001";

                cmd.Parameters.Add("@P_USER_ID", SqlDbType.VarChar, 20);
                cmd.Parameters.Add("@P_USER_PWD", SqlDbType.VarChar, 10);

                cmd.Parameters.Add("@O_WORK_DATE", SqlDbType.VarChar, 8);
                cmd.Parameters.Add("@O_USER_NM", SqlDbType.VarChar, 10);
                cmd.Parameters.Add("@O_USER_INFO", SqlDbType.VarChar, 20);
                cmd.Parameters.Add("@O_MSG", SqlDbType.VarChar, 255);

                cmd.Parameters["@P_USER_ID"].Value = strUserID;
                cmd.Parameters["@P_USER_PWD"].Value = strPassword;

                cmd.Parameters["@O_WORK_DATE"].Direction = ParameterDirection.Output;
                cmd.Parameters["@O_USER_NM"].Direction = ParameterDirection.Output;
                cmd.Parameters["@O_USER_INFO"].Direction = ParameterDirection.Output;
                cmd.Parameters["@O_MSG"].Direction = ParameterDirection.Output;

                dbConn.Open();
                cmd.ExecuteNonQuery();


                result_value = Convert.ToString(cmd.Parameters["@O_USER_NM"].Value);

               
            }
            catch (Exception e)
            {
                return e.Message.ToString();
            }
            finally
            {
                dbConn.Close();
               
            }
            return result_value;
        }

원문 : http://ulgom.net/gomsboard/view.html?t_nm=asp&idx=52&page=1&search=&search_text=

Posted by 정광원
,

OPENXML(MS-SQL SP)

ms-sql 2010. 10. 18. 16:41
declare @doc_xml xml
declare @idnyn int
select @doc_xml = originalxml, @idnyn = idn from doc where idn =@idn

declare @idoc_new int
if @idnyn <> ''
begin
set @idoc_new = 1
EXEC sp_xml_preparedocument @idn OUTPUT, @doc_xml
end
else
begin
set @idoc_new = 0
end

SELECT *
INTO #tmpTable
FROM OPENXML (@idn, '/*[local-name()=''Sanofi'']/*[local-name()=''Content'']', 2)
WITH (
ProductCode varchar(100) './*[local-name()=''ProductCode'']',
ProductName varchar(100) './*[local-name()=''ProductName'']',
ProductType varchar(100) './*[local-name()=''ProductType'']',
Material varchar(100) './*[local-name()=''Material'']',
MaterialType varchar(100) './*[local-name()=''MaterialType'']',
Version varchar(100) './*[local-name()=''Version'']',
Requester varchar(100) './*[local-name()=''Requester'']',
ReasonforChange varchar(100) './*[local-name()=''ReasonforChange'']',
PackType varchar(100) './*[local-name()=''PackType'']'
)

select * from #tmpTable
drop table #tmpTable

if @idoc_new = 1
begin
EXEC sp_xml_removedocument @idn
end

'ms-sql' 카테고리의 다른 글

ms-sql db Link  (4) 2010.10.18
ms-sql 2005 설치  (1) 2010.10.18
SQL 서버의 잠금에 대한 고찰  (1) 2010.09.10
CTE 방식으로 게시판 List Data가져오기  (3) 2010.09.10
CTE 정렬방법  (0) 2010.09.10
Posted by 정광원
,