百度空间 | 百度首页 
               
 
文章列表
 
您正在查看 "Sqlserver" 分类下的文章

2008-05-17 21:04

经常遇到这样的问题,想还原数据库的时候发现有程序在使用该数据库导致无法还原,可以采用以下方法解决:

需要有master数据库的执行权限,然后执行以下sql语句

declare @dbname varchar
set @dbname='labor' -------这里设置对应的数据库名
declare @sql nvarchar(500)
declare @spid int
set @sql='declare getspid cursor for
select spid from sysprocesses where dbid=db_id('''+@dbname+''')'
exec (@sql)
open getspid
fetch next from getspid into @spid
while @@fetch_status<>-1
begin
exec('kill '+@spid)
fetch next from getspid into @spid
end
close getspid
deallocate getspid

类别:Sqlserver | 评论(0) | 浏览()
 
2007-08-08 16:37
select * from ( select *, ROW_NUMBER() OVER (order by practionername,id) as Pos    from Spyder_V_SubmitItemV
where userprofileid=1) as T where T.Pos>1 and T.Pos<15
类别:Sqlserver | 评论(0) | 浏览()
 
2007-07-31 11:26


create PROCEDURE [dbo].[up_PagingLarge]
@TableNames VARCHAR(500),     --表名,可以是多个表,但不能用别名
@PrimaryKey VARCHAR(100),     --主键,可以为空,但@Order为空时该值不能为空
@Fields     VARCHAR(500),      --要取出的字段,可以是多个表的字段,可以为空,为空表示select *
@PageSize INT,                --每页记录数
@CurrentPage INT,             --当前页,0表示第1页
@Filter VARCHAR(500) = '',    --条件,可以为空,不用填 where
@Group VARCHAR(500) = '',     --分组依据,可以为空,不用填 group by
@Order VARCHAR(500) = '',      --排序,可以为空,为空默认按主键升序排列,不用填 order by
@pages bigint output
AS
BEGIN

DECLARE @sql nvarchar(4000),@where1 varchar(800),@where2 varchar(800)
IF @Filter is null or rtrim(@Filter)=''
BEGIN--没有查询条件
   SET @where1=' WHERE '
   SET @where2='   '
END
ELSE
BEGIN--有查询条件
   SET @where1=' WHERE ('+@Filter+') AND '--本来有条件再加上此条件
   SET @where2=' WHERE ('+@Filter+') '--原本没有条件而加上此条件
END
SET @sql='SELECT @Pages=CEILING((COUNT(*)+0.0)/'+CAST(@PageSize AS varchar)+
          ') FROM '+@TableNames+@where2
EXEC sp_executesql @sql,N'@pages int OUTPUT',@pages OUTPUT--计算总页数

     DECLARE @SortColumn VARCHAR(500)
     DECLARE @Operator CHAR(2)
     DECLARE @SortTable VARCHAR(500)
     DECLARE @SortName VARCHAR(500)

     IF @Fields = ''
         SET @Fields = '*'
     IF @Filter = ''
         SET @Filter = 'WHERE 1=1'
     ELSE
         SET @Filter = 'WHERE ' +   @Filter
     IF @Group <> ''
         SET @Group = 'GROUP BY ' + @Group

     IF @Order <> ''
     BEGIN
         DECLARE @pos1 INT, @pos2 INT
SET @Order = UPPER(@Order)
         IF CHARINDEX(' DESC', @Order) > 0
             IF CHARINDEX(' ASC', @Order) > 0
             BEGIN
                 IF CHARINDEX(' DESC', @Order) < CHARINDEX(' ASC', @Order)
                     SET @Operator = '<='
                 ELSE
                     SET @Operator = '>='
             END
             ELSE
                 SET @Operator = '<='
         ELSE
             SET @Operator = '>='

         SET @SortColumn = REPLACE(REPLACE(REPLACE(@Order, ' ASC', ''), ' DESC', ''), ' ', '')
         SET @pos1 = CHARINDEX(',', @SortColumn)
         IF @pos1 > 0
             SET @SortColumn = SUBSTRING(@SortColumn, 1, @pos1-1)
         SET @pos2 = CHARINDEX('.', @SortColumn)
         IF @pos2 > 0
         BEGIN
             SET @SortTable = SUBSTRING(@SortColumn, 1, @pos2-1)
             IF @pos1 > 0
                 SET @SortName = SUBSTRING(@SortColumn, @pos2+1, @pos1-@pos2-1)
             ELSE
                 SET @SortName = SUBSTRING(@SortColumn, @pos2+1, LEN(@SortColumn)-@pos2)
         END
         ELSE
         BEGIN
             SET @SortTable = @TableNames
             SET @SortName = @SortColumn
         END
     END
     ELSE
     BEGIN

SET @SortTable = @TableNames
SET @SortColumn = @PrimaryKey
SET @SortName = @SortColumn

SET @pos1 = CHARINDEX('.', @SortName)
         IF @pos1 > 0
             BEGIN
                 SET @SortTable = SUBSTRING(@SortName, 1, @pos1-1)
                 SET @SortName = SUBSTRING(@SortName, @pos1 + 1, LEN(@SortName))
             END
        
         SET @Order = @SortColumn
         SET @Operator = '>='
     END

     DECLARE @type varchar(50)
     DECLARE @prec int
     SELECT @type=t.name, @prec=c.prec
     FROM sysobjects o
     JOIN syscolumns c on o.id=c.id
     JOIN systypes t on c.xusertype=t.xusertype
     WHERE o.name = @SortTable AND c.name = @SortName

     IF CHARINDEX('char', @type) > 0
     SET @type = @type + '(' + CAST(@prec AS varchar) + ')'

     DECLARE @TopRows INT
     SET @TopRows = @PageSize * @CurrentPage + 1

     Declare @StrSQL NVarChar(2000)
     Set @StrSQL = 'DECLARE @SortColumnBegin ' + CAST(@type AS VARCHAR) + '
   SET ROWCOUNT ' + CAST(@TopRows AS varchar) +'
   SELECT @SortColumnBegin=' + @SortColumn + ' FROM   ' + @TableNames + ' ' + @Filter + ' ' + @Group + ' ORDER BY ' + @Order + '
          SET ROWCOUNT ' + CAST(@PageSize AS VARCHAR) + '
          SELECT ' + @Fields + ' FROM   ' + @TableNames + ' ' + @Filter   + ' AND ' + @SortColumn + ' ' + @Operator + '@SortColumnBegin ' + @Group + ' ORDER BY ' + @Order + '    
       '
     Exec(@StrSQL)
     Print(@StrSQL)

END

类别:Sqlserver | 评论(0) | 浏览()
 
2007-07-31 11:24
ALTER FUNCTION [dbo].[getgroup]
(
-- Add the parameters for the function here
@GroupId bigint
)
RETURNS TABLE
AS



RETURN
(
-- Add the SELECT statement with parameter references here
WITH GroupIdCTE(id)
AS
(
-- 固定成员(AM):
--
SELECT查询无需参考CarPartsCTE
SELECT id FROM cpf_tbl_OrganizationGroup WHERE id = @GroupId UNION ALL
-- 递归成员(RM):
--
SELECT查询参考CarPartsCTE
SELECT cpf_tbl_OrganizationGroup.id
FROM cpf_tbl_OrganizationGroup
INNER JOIN GroupIdCTE ON GroupIdCTE.id = cpf_tbl_OrganizationGroup.parentid
)
SELECT id FROM GroupIdCTE
)
类别:Sqlserver | 评论(0) | 浏览()
 
2007-07-31 11:24
ALTER TRIGGER boke_ad_detail_delete ON [boke_ad_detail]
FOR delete
AS
begin
--当有人点击带金边的展窗的时候,产生数据,将gold更新到bokequn中的edge_gold,并确定is_gold_edge的值

declare c_boke_ad_detail cursor for select ad_id,gold from deleted
declare @ad_id bigint,@gold bigint

open c_boke_ad_detail
fetch next from c_boke_ad_detail into @ad_id,@gold
while @@fetch_status=0
begin
update boke_ad set gold=isnull(gold,0)-@gold where id=@ad_id
update boke_ad set is_ok=1 where id=@ad_id and gold>0

fetch next from c_boke_ad_detail into @ad_id,@gold
end
close c_boke_ad_detail
deallocate c_boke_ad_detail



end
类别:Sqlserver | 评论(0) | 浏览()
 
2007-07-31 11:24
ALTER TRIGGER boke_ad_detail_delete ON [boke_ad_detail]
FOR delete
AS
begin
--当有人点击带金边的展窗的时候,产生数据,将gold更新到bokequn中的edge_gold,并确定is_gold_edge的值

declare c_boke_ad_detail cursor for select ad_id,gold from deleted
declare @ad_id bigint,@gold bigint

open c_boke_ad_detail
fetch next from c_boke_ad_detail into @ad_id,@gold
while @@fetch_status=0
begin
update boke_ad set gold=isnull(gold,0)-@gold where id=@ad_id
update boke_ad set is_ok=1 where id=@ad_id and gold>0

fetch next from c_boke_ad_detail into @ad_id,@gold
end
close c_boke_ad_detail
deallocate c_boke_ad_detail



end
类别:Sqlserver | 评论(0) | 浏览()
 
2007-07-31 11:14

sp_changeobjectowner
更改当前数据库中对象的所有者。

语法
sp_changeobjectowner [ @objname = ] 'object' , [ @newowner = ] 'owner'


最稳妥的处理办法:

EXEC sp_changeobjectowner '所有者.authors', '新的所有者'

类别:Sqlserver | 评论(0) | 浏览()
 
2007-01-18 14:14
Shift+Alt+Enter: 切换全屏编辑
Ctrl+B,T / Ctrl+K,K: 切换书签开关
Ctrl+B,N / Ctrl+K,N: 移动到下一书签
Ctrl+B,P: 移动到上一书签
Ctrl+B,C: 清除全部标签
Ctrl+I: 渐进式搜索
Ctrl+Shift+I: 反向渐进式搜索
Ctrl+F: 查找
Ctrl+Shift+F: 在文件中查找
F3: 查找下一个
Shift+F3: 查找上一个
Ctrl+H: 替换
Ctrl+Shift+H: 在文件中替换
Alt+F12: 查找符号(列出所有查找结果)
Ctrl+Shift+V: 剪贴板循环
Ctrl+左右箭头键: 一次可以移动一个单词
Ctrl+上下箭头键: 滚动代码屏幕,但不移动光标位置。
Ctrl+Shift+L: 删除当前行
Ctrl+M,M: 隐藏或展开当前嵌套的折叠状态
Ctrl+M,L: 将所有过程设置为相同的隐藏或展开状态
Ctrl+M,P: 停止大纲显示
Ctrl+E,S: 查看空白
Ctrl+E,W: 自动换行
Ctrl+G: 转到指定行
Shift+Alt+箭头键: 选择矩形文本
Alt+鼠标左按钮: 选择矩形文本
Ctrl+Shift+U: 全部变为大写
Ctrl+U: 全部变为小写

代码快捷键
Ctrl+J / Ctrl+K,L: 列出成员
Ctrl+Shift+空格键 / Ctrl+K,P: 参数信息
Ctrl+K,I: 快速信息 
Ctrl+E,C / Ctrl+K,C: 注释选定内容
Ctrl+E,U / Ctrl+K,U: 取消选定注释内容
Ctrl+K,M: 生成方法存根
Ctrl+K,X: 插入代码段
Ctrl+K,S: 插入外侧代码 
F12: 转到所调用过程或变量的定义

窗口快捷键

Ctrl+W,W: 浏览器窗口
Ctrl+W,S: 解决方案管理器
Ctrl+W,C: 类视图
Ctrl+W,E: 错误列表
Ctrl+W,O: 输出视图
trl+W,P: 属性窗口
Ctrl+W,T: 任务列表
Ctrl+W,X: 工具箱
Ctrl+W,B: 书签窗口
Ctrl+W,U: 文档大纲
Ctrl+D,B: 断点窗口
Ctrl+D,I: 即时窗口
Ctrl+Tab: 活动窗体切换
Ctrl+Shift+N: 新建项目
Ctrl+Shift+O: 打开项目
Ctrl+Shift+S: 全部保存
Shift+Alt+C: 新建类
Ctrl+Shift+A: 新建项
Shift+Alt+Enter: 切换全屏编辑
Ctrl+B,T / Ctrl+K,K: 切换书签开关
Ctrl+B,N / Ctrl+K,N: 移动到下一书签
Ctrl+B,P: 移动到上一书签
Ctrl+B,C: 清除全部标签
Ctrl+I: 渐进式搜索
Ctrl+Shift+I: 反向渐进式搜索
Ctrl+F: 查找
Ctrl+Shift+F: 在文件中查找
F3: 查找下一个
Shift+F3: 查找上一个
Ctrl+H: 替换
Ctrl+Shift+H: 在文件中替换
Alt+F12: 查找符号(列出所有查找结果)
Ctrl+Shift+V: 剪贴板循环
Ctrl+左右箭头键: 一次可以移动一个单词
Ctrl+上下箭头键: 滚动代码屏幕,但不移动光标位置。
Ctrl+Shift+L: 删除当前行
Ctrl+M,M: 隐藏或展开当前嵌套的折叠状态
Ctrl+M,L: 将所有过程设置为相同的隐藏或展开状态
Ctrl+M,P: 停止大纲显示
Ctrl+E,S: 查看空白
Ctrl+E,W: 自动换行
Ctrl+G: 转到指定行
Shift+Alt+箭头键: 选择矩形文本
Alt+鼠标左按钮: 选择矩形文本
Ctrl+Shift+U: 全部变为大写
Ctrl+U: 全部变为小写
类别:Sqlserver | 评论(0) | 浏览()
 
2006-09-12 09:00
类别:Sqlserver | 评论(4) | 浏览()
 
2006-07-25 15:19

<img src="cid:123">

使用cid:标记,表明图片是放在一个叫123的附件中的
然后加入一个附件,指定为
content-type: image/gif
content-id: <123> 即上面那个123
content-disposition: inline; filename="sdfsdf" filename是随便指定的
content-transfer-encodinf: base64

这里是附件内容要求用base64编码

类别:Sqlserver | 评论(3) | 浏览()
 
2006-07-24 15:39

Command Identifiers

2D-Position

Allows absolutely positioned elements to be moved by dragging.

AbsolutePosition

Sets an element's position property to "absolute."

BackColor

Sets or retrieves the background color of the current selection.

BlockDirLTR

Not currently supported.

BlockDirRTL

Not currently supported.

Bold

Toggles the current selection between bold and nonbold.

BrowseMode

Not currently supported.

ClearAuthenticationCache

Clears all authentication credentials from the cache. Applies only to execCommand.

Copy

Copies the current selection to the clipboard.

CreateBookmark

Creates a bookmark anchor or retrieves the name of a bookmark anchor for the current selection or insertion point.

CreateLink

Inserts a hyperlink on the current selection, or displays a dialog box enabling the user to specify a URL to insert as a hyperlink on the current selection.

Cut

Copies the current selection to the clipboard and then deletes it.

Delete

Deletes the current selection.

DirLTR

Not currently supported.

DirRTL

Not currently supported.

EditMode

Not currently supported.

FontName

Sets or retrieves the font for the current selection.

FontSize

Sets or retrieves the font size for the current selection.

ForeColor

Sets or retrieves the foreground (text) color of the current selection.

FormatBlock

Sets the current block format tag.

Indent

Increases the indent of the selected text by one indentation increment.

InlineDirLTR

Not currently supported.

InlineDirRTL

Not currently supported.

InsertButton

Overwrites a button control on the text selection.

InsertFieldset

Overwrites a box on the text selection.

InsertHorizontalRule

Overwrites a horizontal line on the text selection.

InsertIFrame

Overwrites an inline frame on the text selection.

InsertImage

Overwrites an image on the text selection.

InsertInputButton

Overwrites a button control on the text selection.

InsertInputCheckbox

Overwrites a check box control on the text selection.

InsertInputFileUpload

Overwrites a file upload control on the text selection.

InsertInputHidden

Inserts a hidden control on the text selection.

InsertInputImage

Overwrites an image control on the text selection.

InsertInputPassword

Overwrites a password control on the text selection.

InsertInputRadio

Overwrites a radio control on the text selection.

InsertInputReset

Overwrites a reset control on the text selection.

InsertInputSubmit

Overwrites a submit control on the text selection.

InsertInputText

Overwrites a text control on the text selection.

InsertMarquee

Overwrites an empty marquee on the text selection.

InsertOrderedList

Toggles the text selection between an ordered list and a normal format block.

InsertParagraph

Overwrites a line break on the text selection.

InsertSelectDropdown

Overwrites a drop-down selection control on the text selection.

InsertSelectListbox

Overwrites a list box selection control on the text selection.

InsertTextArea

Overwrites a multiline text input control on the text selection.

InsertUnorderedList

Toggles the text selection between an ordered list and a normal format block.

Italic

Toggles the current selection between italic and nonitalic.

JustifyCenter

Centers the format block in which the current selection is located.

JustifyFull

Not currently supported.

JustifyLeft

Left-justifies the format block in which the current selection is located.

JustifyNone

Not currently supported.

JustifyRight

Right-justifies the format block in which the current selection is located.

LiveResize

Causes the MSHTML Editor to update an element's appearance continuously during a resizing or moving operation, rather than updating only at the completion of the move or resize.

MultipleSelection

Allows for the selection of more than one site selectable element at a time when the user holds down the SHIFT or CTRL keys.

Open

Not currently supported.

Outdent

Decreases by one increment the indentation of the format block in which the current selection is located.

OverWrite

Toggles the text-entry mode between insert and overwrite.

Paste

Overwrites the contents of the clipboard on the current selection.

PlayImage

Not currently supported.

Print

Opens the print dialog box so the user can print the current page.

Redo

Not currently supported.

Refresh

Refreshes the current document.

RemoveFormat

Removes the formatting tags from the current selection.

RemoveParaFormat

Not currently supported.

SaveAs

Saves the current Web page to a file.

SelectAll

Selects the entire document.

SizeToControl

Not currently supported.

SizeToControlHeight

Not currently supported.

SizeToControlWidth

Not currently supported.

Stop

Not currently supported.

StopImage

Not currently supported.

StrikeThrough

Not currently supported.

Subscript

Not currently supported.

Superscript

Not currently supported.

UnBookmark

Removes any bookmark from the current selection.

Underline

Toggles the current selection between underlined and not underlined.

Undo

Not currently supported.

Unlink

Removes any hyperlink from the current selection.

Unselect

Clears the current selection.

类别:Sqlserver | 评论(0) | 浏览()
 
     
 
 
文章分类
 
 
 
 
Dotnet(41)
 
 
 
 
Flex(6)
 
 
 
     
 
文章存档
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
     
 
最新文章评论
   

回复bbpnb:算不上,鱼太小了,如果半斤一条,那就爽了!
 

大丰收啊
 

最近正在研究委托呢,楼主高见,在此谢过~~
 

太谢谢了,弄了好久,看了你的,搞定了,高兴!!
 

为什么找不到document这个东西呢?
 
     


©2009 Baidu