/****** Object: StoredProcedure [dbo].[GET_TableScript_MSSQL] Script Date: 06/15/2012 11:59:00 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO /*============================================================== 名称: GET_TableScript_MSSQL 功能: 获取c
/****** Object: StoredProcedure [dbo].[GET_TableScript_MYSQL] Script Date: 06/15/2012 13:05:14 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO /*============================================================== 名称: GET_TableScript_MYSQL 功能: 生成单
/****** Object: StoredProcedure [dbo].[GET_TableScript_ORACLE] Script Date: 06/15/2012 13:07:16 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO /*============================================================== 名称: GET_TableScript_ORACLE 功能: 生
Set nocount on ), ) DECLARE Tbls CURSOR FOR ),isnull(g.[value],'-')) AS TABLE_COMMENT FROM INFORMATION_SCHEMA.COLUMNS b inner join sys.tables a on a.name = b.TABLE_NAME ) --put any exclusions here --where table_name not like '%old' where b.table_name
use fpErp --指定要生成数据字典的数据库 go SELECT 表名=case when a.colorder=1 then d.name else '' end, 表说明=case when a.colorder=1 then isnull(f.value,'') else '' end, 字段序号=a.colorder, 字段名=a.name, 标识=case when COLUMNPROPERTY(a.id,a.name,'IsIdentity')=1 then '√'else
方法一: declare @StartTime datetime declare @EndTime datetime set @StartTime ='2019-02-1 00:00' set @EndTime ='2019-02-19 00:00' select dateadd(DAY,number,@StartTime) as dt from master.dbo.spt_values where type ='P' and number <=DATEDIFF(DAY, @StartTime
一般我们用SELECT .... INTO语句生成的表字段都是允许为NULL.而如果我们需要改成NOT NULL呢 select 'ALTER TABLE dbo.XXXXXXX ALTER COLUMN ' + QUOTENAME(c.name) + ' ' + t.name + case when t.name in ('nvarchar','nchar') as nvarchar) +')' when t.name in ('varchar','binary', 'char', 'varb
有时工作中要建个分区函数,可是像日期这种分区函数要是搞个几百个的值那不是要搞死我.于是写了点代码自动生成一个从1990年开始的按月的分区函数和对应的分区主题 USE [TestDB] GO DECLARE @STR NVARCHAR(MAX) SET @STR = 'CREATE PARTITION FUNCTION [PF_RangeByMonth_FromYear1990](DATETIME) AS RANGE LEFT FOR VALUES (' DECLARE @STR2 NVARCHA
if object_id('MyDB.dbo.Numbers') is not null drop table MyDB.dbo.Numbers go use [MyDB] go create table dbo.Numbers(ID INT NOT NULL) go create unique clustered index ix_uniq_clst_numbers_id on dbo.Numbers(id) go with t as ( select row_number() over (o
SELECT TOP 100 PERCENT --a.id, CASE WHEN a.colorder = 1 THEN d.name ELSE '' END AS 表名, CASE WHEN a.colorder = 1 THEN isnull(f.value, '') ELSE '' END AS 表说明, a.colorder AS 字段序号, a.name AS 字段名, CASE WHEN COLUMNPROPERTY(a.id,