首页 > 代码库 > 生成表结构
生成表结构
USE [DataInputTest]GO/****** Object: StoredProcedure [dbo].[CreateTableList] Script Date: 12/27/2014 11:12:37 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGO-- =============================================-- Author: <Author,,Name>-- Create date: <Create Date,,>-- Description: <Description,,>-- =============================================ALTER PROCEDURE [dbo].[CreateTableList] ASBEGINdelete from dbo.Table_Name;insert into dbo.Table_NameSELECT NAME as TableName ,dbo.f_Primary_Keystr(name) as Primary_Key,dbo.f_Field_Liststr(id) as Field_List,‘TMStamp‘ as [TimeSpan], ‘FinChinaData‘ as DataBaseName FROM FinChinaData.dbo.SYSOBJECTS WHERE TYPE=‘U‘ order by NAMEENDUSE [DataInputTest]GO/****** Object: UserDefinedFunction [dbo].[f_Field_Liststr] Script Date: 12/27/2014 11:13:19 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOALTER FUNCTION [dbo].[f_Field_Liststr](@id int)RETURNS varchar(8000)AS BEGIN DECLARE @r varchar(8000) SET @r = ‘‘ SELECT @r = @r + ‘,‘ + name FROM FinChinaData.dbo.[syscolumns] WHERE id=@id RETURN STUFF(@r, 1, 1, ‘‘)ENDUSE [DataInputTest]GO/****** Object: UserDefinedFunction [dbo].[f_Primary_Keystr] Script Date: 12/27/2014 11:13:30 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOALTER FUNCTION [dbo].[f_Primary_Keystr](@TABLE_NAME varchar(200))RETURNS varchar(8000)AS BEGIN DECLARE @r varchar(8000) SET @r = ‘‘ SELECT @r = @r + ‘,‘ + COLUMN_NAME FROM FinChinaData.INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE TABLE_NAME =@TABLE_NAME RETURN STUFF(@r, 1, 1, ‘‘)END
生成表结构
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。