SQL 笔记

——————-选中表名 配置为Ctrl+3 即可select * 表
USE [NB]
GO
/* 对象: StoredProcedure [dbo].[SP_Select] 脚本日期: 05/28/2015 21:46:25 */
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
Create Proc [dbo].[SP_Select]
@OName varchar( 100)
As
Declare @Str Varchar (1000),
@dbname varchar( 40)
set @dbname= db_name()
Set @Str= ‘Select * from ‘+@dbname +’.dbo.’+ @OName
Exec ( @Str)

——————-选中表名 配置为Ctrl+8 即可查此表的所有列名
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[sp_syscolumns] –Exec sp_syscolumns ‘eemployee’
@Object NVARCHAR( 1000)
As
/*
Function:取得一个对象中的所有列的项目 (主要针对表)
Remark: Create By Deam L 2013/4/7
*/
Begin
Set nocount on

Declare @Name NVARCHAR (1000)
Select  @Name= Isnull(@Name +',', '')+name From syscolumns Where id=object_id( @Object)
Print   @Name

Set nocount off

END

你可能感兴趣的:(SQL 笔记)