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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
namespace ConsoleApp { | |
class Program { | |
static void Main( string[] args ) { | |
Console.WriteLine( "Hello gist!!" ); | |
} |
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Net; | |
using System.Net.Mail; | |
namespace ConsoleApp { | |
static class Program { | |
static void Main( string[] args ) { |
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Diagnostics; | |
namespace ConsoleApp { | |
static class Program { | |
static void Main( string[] args ) { | |
var source = "ConsoleApp"; // イベントソース名 |
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 | |
sys.tables.name, | |
sys.columns.name, | |
sys.types.name | |
from sys.tables | |
inner join sys.columns | |
on sys.tables.object_id = sys.columns.object_id | |
inner join sys.types | |
on sys.columns.user_type_id = sys.types.user_type_id | |
order by |
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 @table sysname = 'table_name'; | |
declare @column sysname = 'column_name'; | |
select | |
sys.default_constraints.name, * | |
from sys.tables | |
inner join sys.columns | |
on sys.tables.object_id = sys.columns.object_id | |
inner join sys.default_constraints | |
on sys.tables.object_id = sys.default_constraints.parent_object_id and |
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
-- cursorを宣言 | |
declare cur cursor | |
for | |
select ... | |
-- cursorを開く | |
open cur; | |
-- 1行ごとにデータを取り出す | |
fetch next from cur into @v1, @v2, ...; |
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
with cte_columns as( | |
select | |
sys.tables.object_id, | |
sys.columns.column_id, | |
sys.tables.name as table_name, | |
sys.columns.name as column_name | |
from sys.tables | |
inner join sys.columns | |
on sys.tables.object_id = sys.columns.object_id | |
where |
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( | |
Name sysname not null, | |
Rows int not null | |
); | |
-- テーブル名を取得するカーソル | |
declare cur cursor | |
for | |
select |
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace ConsoleApp { | |
class Program { | |
static void Main( string[] args ) { | |
var items = new HashSet<int> { 0, 1, 2, 3, 4, }; | |
// otherが同じ要素を含んでいるかどうか |
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
/* | |
指定DBを指定フォルダにバックアップ | |
バックアップファイル名には日付の文字列が含まれる | |
*/ | |
declare @dbName sysname = N'DB名'; | |
declare @folder nvarchar( max ) = N'バックアップフォルダ(\で終わる必要あり)'; | |
declare @date datetime = getdate(); | |
declare @ymd char( 8 ) = convert( char( 8 ), @date, 112 ); -- yymmdd | |
declare @hms char( 6 ) = replace( convert( char( 8 ), @date, 108 ), ':', '' ); -- hh:mm:ss -> hhmmss |
OlderNewer