동적 쿼리에서의 text 사용법.

Posted at 2008.12.06 01:07 | Posted in 데이타베이스/MSSQL


=======================================================

CREATE PROCEDURE DBO.SP_BOARD_INSERT
@table varchar(50),
@tid int,
@subject varchar(200),
@content text,
@uid varchar(20),
@name varchar(20),
@email varchar(100)

AS
DECLARE @param nvarchar(500), @SQL nvarchar(2000)

SET @param = '
@tid int,
@subject varchar(200),
@content text,
@uid varchar(20),
@name varchar(20),
@email varchar(100)
'

SET @SQL = '
INSERT '+@table+' ( TID, SUBJECT, CONTENT, USER_NAME, USER_ID, USER_EMAIL)
VALUES(@tid, @subject, @content, @name, @uid, @email) '

EXEC SP_EXECUTESQL @SQL, @param,
@tid = @tid,
@subject = @subject,
@content = @content,
@uid = @uid,
@name = @name,
@email = @email
GO
=======================================================



Name __

Password __

Link (Your Website)

Comment

SECRET | 비밀글로 남기기