 |
|
@vProfit1 = 3
@vProfit2 = 5
@vProfit3 = 7
@SERVER = 'korea.server.'
ถ้าแบบนี้จะติด Error Incorrect syntax near '+',
Code (MSSQL)
ALTER PROCEDURE [dbo].[UpdateConfig]
@vProfit1 as int,
@vProfit2 as int,
@vProfit3 as int,
@SERVER VARCHAR(MAX)
AS
BEGIN
update @SERVER + dbo.Configuration
set Profit1=@vProfit1,
Profit2=@vProfit2,
Profit3=@vProfit3
END
ถ้าทำรูปแบบนี้จะติด Error Must declare the scalar variable "@vProfit1".
Code (MSSQL)
ALTER PROCEDURE [dbo].[UpdateConfig]
@vProfit1 as int,
@vProfit2 as int,
@vProfit3 as int,
@SERVER VARCHAR(MAX)
AS
DECLARE @vQuery nvarchar(MAX)
SET @vQuery = N'
BEGIN
update ' + @SERVER + 'dbo.Configuration
set Profit1=@vProfit1,
Profit2=@vProfit2,
Profit3=@vProfit3
END
'
EXEC (@vQuery)
Tag : .NET, Ms SQL Server 2008, C#
|
ประวัติการแก้ไข 2018-02-09 11:11:36 2018-02-09 11:12:28 2018-02-09 12:13:20
|
 |
 |
 |
 |
Date :
2018-02-09 11:02:30 |
By :
nPointXer |
View :
795 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |