一般情況下:
創(chuàng)新互聯(lián)建站專注于企業(yè)全網(wǎng)營銷推廣、網(wǎng)站重做改版、紅橋網(wǎng)站定制設(shè)計、自適應(yīng)品牌網(wǎng)站建設(shè)、H5建站、商城網(wǎng)站建設(shè)、集團公司官網(wǎng)建設(shè)、成都外貿(mào)網(wǎng)站制作、高端網(wǎng)站制作、響應(yīng)式網(wǎng)頁設(shè)計等建站業(yè)務(wù),價格優(yōu)惠性價比高,為紅橋等各大城市提供網(wǎng)站開發(fā)制作服務(wù)。
1、人們不會直接操作SQL Server進(jìn)行數(shù)據(jù)的管理和查詢,只有管理、設(shè)計人員或是學(xué)習(xí)編程的朋友才會在SQL Server自帶的管理器里進(jìn)行數(shù)據(jù)的管理和查詢工作。
2、設(shè)計好了的帶SQL Server查詢的應(yīng)用(或叫程序)會有相對簡單的界面,你填好需要查詢的條件,進(jìn)行簡單的操作就能查到你能查到的,想查到的數(shù)據(jù)。具體的如何查,取決于軟件設(shè)計者的設(shè)計。
二、直接操作SQL Server進(jìn)行查詢:
各版本的SQL Sserver的具體做法不相同,但基本思路是一樣的,登錄SQL Server的管理器,然后使用管理器的基本功能及標(biāo)準(zhǔn)的SQL語句進(jìn)行查詢。
三、如果上面說的你一點兒也不明白,那說明你可能沒有這方面的知識,建議你搜索“Microsoft SQL Server 2008 R2基礎(chǔ)教程”,然后耐心地翻看一下。
1.這是查詢與當(dāng)前時間在同一周內(nèi)的數(shù)據(jù),sql語句是:
2.select
*
from
表
where
datediff(week,時間字段,getdate())=0
3.也可以稍作修改用來查詢與指定日期在同一周內(nèi)的數(shù)據(jù):
4.select
*
from
表
where
datediff(week,時間字段,'2002-01-01')=0
5.select
*
from
表
where
startdate
between
指定日期
and
指定日期
6.select
*
from
表
where
leavedate
between
指定日期
and
指定日期
7.查詢一段時間(
不需要固定時間的,只需要前后間隔時間的)
8.select
*
from
表
where
datediff(day,startdate,leavedate)7
and
startdate
=
指定日期9.select
*
from
表
where
datediff(day,startdate,leavedate)7
and
leavedate
=
指定日期
這是查詢此日期開始時間到離開時間在七天之間的所有數(shù)據(jù),
打開SQL Server Management Studio 界面。法1:單擊工具欄的“新建查詢”;方法2:或右擊數(shù)據(jù)庫名稱-》“新建查詢”;方法3:選中數(shù)據(jù)表-》編寫表腳本為-》SELECT到-》新查詢編輯器窗口。在數(shù)據(jù)庫對象下拉框中選擇“BooksDB”,在查詢編輯器輸入?yún)^(qū)中輸入Transact-SQL語句,然后點擊工具欄或“查詢”菜單中的“!執(zhí)行”,執(zhí)行輸入?yún)^(qū)的Transact-SQL語句
SQL Server中查詢用戶的對象權(quán)限和角色的方法 \x0d\x0a\x0d\x0a-- 查詢用戶的object權(quán)限\x0d\x0aexec sp_helprotect NULL, 'UserName'\x0d\x0a-- 查詢用戶擁有的role\x0d\x0aexec sp_helpuser 'UserName'\x0d\x0a-- 查詢哪些用戶擁有指定的系統(tǒng)role\x0d\x0aexec sp_helpsrvrolemember 'sysadmin'\x0d\x0a-- 可查詢嵌套role\x0d\x0aWITH tree_roles as\x0d\x0a(\x0d\x0aSELECT role_principal_id, member_principal_id\x0d\x0aFROM sys.database_role_members\x0d\x0aWHERE member_principal_id = USER_ID('UserName')\x0d\x0aUNION ALL\x0d\x0aSELECT c.role_principal_id,c.member_principal_id\x0d\x0aFROM sys.database_role_members as c\x0d\x0ainner join tree_roles\x0d\x0aon tree_roles.member_principal_id = c.role_principal_id\x0d\x0a)\x0d\x0aSELECT distinct USER_NAME(role_principal_id) RoleName\x0d\x0aFROM tree_roles\x0d\x0a\x0d\x0a-- 其他權(quán)限相關(guān)基本表\x0d\x0aselect * from sysusers\x0d\x0aselect * from syspermissions\x0d\x0a\x0d\x0a-- Who has access to my SQL Server instance?\x0d\x0aSELECT\x0d\x0aname as UserName, type_desc as UserType, is_disabled as IsDisabled\x0d\x0aFROM sys.server_principals\x0d\x0awhere type_desc in('WINDOWS_LOGIN', 'SQL_LOGIN')\x0d\x0aorder by UserType, name, IsDisabled\x0d\x0a\x0d\x0a-- Who has access to my Databases?\x0d\x0aSELECT\x0d\x0adp.name as UserName, dp.type_desc as UserType, sp.name as LoginName, sp.type_desc as LoginType\x0d\x0aFROM sys.database_principals dp\x0d\x0aJOIN sys.server_principals sp ON dp.principal_id = sp.principal_id\x0d\x0aorder by UserType\x0d\x0a\x0d\x0aselect * from sys.database_principals\x0d\x0a\x0d\x0a-- Server Roles\x0d\x0aselect\x0d\x0ap.name as UserName, p.type_desc as UserType, pp.name as ServerRoleName, pp.type_desc as ServerRoleType\x0d\x0afrom sys.server_role_members roles\x0d\x0ajoin sys.server_principals p on roles.member_principal_id = p.principal_id\x0d\x0ajoin sys.server_principals pp on roles.role_principal_id = pp.principal_id\x0d\x0awhere pp.name in('sysadmin')\x0d\x0aorder by ServerRoleName, UserName\x0d\x0a\x0d\x0a-- Database Roles\x0d\x0aSELECT\x0d\x0ap.name as UserName, p.type_desc as UserType, pp.name as DBRoleName, pp.type_desc as DBRoleType, pp.is_fixed_role as IfFixedRole\x0d\x0aFROM sys.database_role_members roles\x0d\x0aJOIN sys.database_principals p ON roles.member_principal_id = p.principal_id\x0d\x0aJOIN sys.database_principals pp ON roles.role_principal_id = pp.principal_id\x0d\x0awhere pp.name in('db_owner', 'db_datawriter')\x0d\x0a\x0d\x0a-- What can these users do?\x0d\x0aSELECT\x0d\x0agrantor.name as GrantorName, dp.state_desc as StateDesc, dp.class_desc as ClassDesc, dp.permission_name as PermissionName ,\x0d\x0aOBJECT_NAME(major_id) as ObjectName, GranteeName = grantee.name\x0d\x0aFROM sys.database_permissions dp\x0d\x0aJOIN sys.database_principals grantee on dp.grantee_principal_id = grantee.principal_id\x0d\x0aJOIN sys.database_principals grantor on dp.grantor_principal_id = grantor.principal_id\x0d\x0awhere permission_name like '%UPDATE%'