共 29 篇文章 |
|
SELECT SysObjects.[Name] as TableName,SysColumns.[Name] as ColumnName,SysTypes.[Name] AS [Name],SysColumns.[Length] AS [Length]FROM.SysObjects INNER JOIN SysColumnsON SysObjects.[Id] = SysColumns.[Id]INNER JOIN SysTypesON SysTypes.[xtype] = SysColumns.[xtype]WHERE SysObjects.[type] = ''U''AND SysTypes.... 阅39 转0 评0 公众公开 13-04-21 15:51 |
阅601 转2 评0 公众公开 13-04-11 07:32 |
RETURN如果循环insert的例子 DECLARE @strLoginID VARCHAR(16)BEGINdeclare db cursor forSELECT LoginID FROM dbo.s_Users WHERE len(UnitCoding) in(9,12)ENDopen dbfetch next from db into @strLoginIDwhile @@fetch_status = 0 BEGINinsert into s_P_Userselect @strLoginID,LevelID from s_P_User where LoginID = ''aa''... 阅503 转3 评0 公众公开 12-02-17 05:56 |
select 字段1 from 表1 where 字段1.IndexOf("云")=1;这条语句不对的原因是indexof()函数不是sql函数,改成sql对应的函数就可以了。三、取子串函数1、left() LEFT (<character_expression>, <integer_expression>)返回character_expression 左起 integer_expression 个字符。CHARINDEX (<’substring_expression’... 阅95 转3 评0 公众公开 12-01-12 10:04 |
declare @field1 intdeclare @field2 intdeclare cur CURSOR LOCAL for select field1, field2 from sometable where someotherfield is null.fetch next from cur into @field1, @field2.--execute your sproc on each row exec uspYourSproc @field1, @field2.fetch next from cur into @field1, @field2END.close curdeallocate cur. 阅60 转4 评0 公众公开 12-01-12 09:44 |
SET @result=@result+'' AND '' IF SUBSTRING(@s,14,1)=''0'' SET @result=@result+''zero'' ELSE SET @result=@result+RTRIM(SUBSTRING(@numbers,CAST(SUBSTRING(@s,14,1) AS int)*10-9,10)) IF SUBSTRING(@s,15,1)<>''0'' SET @result=@result+'' ''... 阅224 转14 评0 公众公开 12-01-12 07:39 |
select datename(day,CURRENT_TIMESTAMP)select datename(month,CURRENT_TIMESTAMP)select datename(year,CURRENT_TIMESTAMP)select datename(hour,CURRENT_TIMESTAMP)select datename(minute,CURRENT_TIMESTAMP)select datename(week,CURRENT_TIMESTAMP)select datename(weekday,CURRENT_TIMESTAMP)-----------------------------------------... 阅264 转16 评0 公众公开 12-01-12 07:38 |
//删除索引名tb_hr_personl_info_ix drop index tb_hr_personl_info.tb_hr_personl_info_ix -----------------------------------------------------------4.6视图view4.6.1视图view的概念:视图不是表,也不是表数据的备份,在数据库模式中只是select语句的集合!语句列表可以包括:* CREATE DATABASE* CREATE DEFAULT* CREATE FUNCTION* CREATE... 阅288 转17 评0 公众公开 12-01-12 07:37 |
alter table tb_hr_gzadd constraint tb_hr_gz_ck check(gz >=0 and gz <=1000000)/*为此表添加主键约束*/alter table tb_hr_personl_infoadd constraint tb_hr_personl_info_pk Primary Key (userid)/*为个人信息表添加外键约束*/alter table tb_hr_personl_infoadd constraint tb_hr_personl_info__bm_fkforeign key(bm)references tb_... 阅639 转19 评0 公众公开 12-01-12 07:36 |
代码://求出每名销售人员的销售金额select rep,sum(amount) from orders group by rep//每个销售点分配了多少销售人员select rep_office,count(*) from salesreps group by rep_office//计算每名销售人员的每个客户和订单金额select cust,rep,sum(amount) from orders group by cust,rep//Having子句应用select rep,avg(amount) from orders ha... 阅275 转16 评0 公众公开 12-01-12 07:35 |