[SP]up_Select
Posted In:
MSSQL
,
Stored Procedure
.
By 卡西卡
將資料表所有欄位組成SELECT句
CREATE PROCEDURE up_Select (
@TABLE_NAME NVARCHAR(128) -- 資料表名稱
)AS
DECLARE @BUF NVARCHAR(1000)
DECLARE @COLUMN_NAME NVARCHAR(128)
SET @BUF=''
DECLARE curView CURSOR FOR
SELECT COLUMN_NAME
FROM [INFORMATION_SCHEMA].[COLUMNS]
WHERE TABLE_NAME=@TABLE_NAME
OPEN curView
FETCH curView
INTO @COLUMN_NAME
WHILE @@FETCH_STATUS = 0
BEGIN -- WHILE
SELECT @BUF=@BUF + @COLUMN_NAME + ','
FETCH curView INTO @COLUMN_NAME
END -- WHILE
CLOSE curView
DEALLOCATE curView
IF Len(@BUF)>0
BEGIN
SELECT @BUF = LEFT(@BUF,LEN(@BUF)-1)
PRINT 'SELECT'
PRINT @BUF
PRINT 'FROM ['+@TABLE_NAME+']'
END
ELSE
PRINT '(none)'
1 Response to [SP]up_Select
curry 6
jordan shoes
coach outlet online
nike air max 97
yeezy boost 350 v2
nike shoes
yeezys
golden goose
golden goose
yeezy boost 350 v2
Something to say?