This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//In Service | |
using (var scope = _serviceScopeFactory.CreateScope()) | |
{ | |
var dbContext = scope.ServiceProvider.GetRequiredService<RicoDbContext>(); | |
await dbContext.Products.AddAsync(product) | |
.ConfigureAwait(false); | |
var serial = product.Serial; | |
return await dbContext.SaveChangesAsync() | |
.ConfigureAwait(false); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Create or alter proc [dbo].[usp_spaceused] | |
@objname nvarchar(776) = null | |
as | |
declare @id int -- The object id that takes up space | |
,@type character(2) -- The object type. | |
,@pages bigint -- Working variable for size calc. | |
,@dbname sysname | |
,@dbsize bigint | |
,@logsize bigint | |
,@reservedpages bigint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--結果表 | |
declare @result table(rownums int,TITLE_ID varchar(10),DATEX varchar(10),DC varchar(1),ST int,D_AMT int,C_AMT int, total int default(0)) | |
;with mycte | |
as | |
( | |
select rownums=ROW_NUMBER() over (partition by a.TITLE_ID order by a.TITLE_ID), | |
a.TITLE_ID,b.DATEX,a.DC,a.ST,b.D_AMT,b.C_AMT,0 as total | |
from ta a join td b | |
on a.TITLE_ID=b.TITLE_ID | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR ALTER PROCEDURE [usp_ConvertTableToClass] | |
@tablename SYSNAME,@namespace varchar(50) | |
AS | |
SET NOCOUNT ON | |
DECLARE @step int,@maxcount int | |
DECLARE @temp TABLE | |
( | |
codeline INT, | |
code nvarchar(4000) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare @result table | |
( | |
serial int identity(1,1), | |
owner varchar(100), | |
tname varchar(500), | |
sname varchar(100) | |
) | |
insert into @result | |
select sch.name as 'Owner',obj.name as '資料表名稱',st.name as '統計值名稱' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create function [dbo].[myStrSplit] | |
( | |
@inputcontent nvarchar(max), | |
@schar char(1) | |
) | |
RETURNS TABLE | |
as | |
return | |
( | |
with mysplie(i,j) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select GETDATE() | |
go | |
--使用cursor串連 | |
declare | |
@owner varchar(100), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select GETDATE() | |
go | |
--使用XML 串連 | |
declare @s nvarchar(max) = N''; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select GETDATE() | |
go | |
--使用直接串連 | |
declare @s nvarchar(max) = N''; | |
SELECT @s += CHAR(13) + CHAR(10) + 'drop statistics ' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select GETDATE() | |
go | |
--使用while loop | |
declare @result table | |
( |
OlderNewer