Basic SQL statement (2)

zhaozj2021-02-16  58

Basic SQL statement search

1. Import the data in the DB in the local database name DB into the R table in the remote library name - Query Analyzer Connect Local SQL, Execute Statement: Insert OpenRowSet ('Sqloledb', 'Remote Server Name " ; 'Landing username'; 'password', far.dbo.r) Select * from db.dbo.d (Source: [ZJCXC (Zou Jian)] http://community.9cbs.net/expert/topic/3141 / 3141185.xml?temp=.276333)

2. Each table displays the current number of rows SELECT TOP 100 Percent sysobjects.name, sysindexes.rows FROM sysindexes with (nolock) JOIN sysobjects with (nolock) ON sysindexes.id = sysobjects.id AND sysobjects.xtype = 'u' WHERE Sysindexes.indid IN (0, 1) Order by sysobjects.name ASC (Source: http://community.9cbs.net/expert/topic/3124/3124563.xml? Temp = .1386072)

3. How do I import the encrypted stored procedure into another library? 1. If your database is SQL7.0, you can directly generate the script of the stored procedure. Encryption can also be generated 2. If you are SQL2000, then there is no way, you can only decrypt first, then execute the script to create a stored procedure (Source: [ZJCXC (Zou Jian)] http://community.9cbs.net/expert/topic/3092/3092898.xml?temp=.2777979)

4. How to get the server's IP address crete table #ip (id int identity (1, 1), re varchar (200)) Declare @s varchar (1000) set @ s = 'ping' left (@@ servername, charindex ('/', @@ servername '/') - 1) '-A -N 1 -L 1'Insert #ip (re) exec master@xp_cmdshell @sselect server name = @@ servername, IP address = stuff (Left (Re, Charindex ('], RE) -1), 1, Charindex (' [', re),' ') from #ipwhere id = 2drop Table #ip (Source: [ZJCXC (Zou Jian)] http://community.9cbs.net/expert/topic/3142/3142434.xml?temp=.6255457)

5. How to get the description of the column in a list of columns Select * from :: Fn_ListextendedProperty ('ms_description', 'user', 'dbo', 'table', 'table name,' column ', default)

6. How do I check if a view is called by another view? EXEC SP_Depends 'view name'

7. There is a table A with B and C, how to change the C field name to D field name. Exec sp_rename 'a.c', 'd', 'column'8. How to disable all triggers - disabled A trigger ALTER TABLE on a table, your table disable trigger your trigger

- Enable a trigger ALTER TABLE on a table ENABLE TRIGGER Your trigger

- Disable all triggers on a table ALTER TABLE Your table Disable Trigger All

- Enable all triggers on a table Alter Table Your table Enable Trigger All

- Disable all triggers on all tables EXEC SP_MSFOREACHTABLE 'ALTER TABLE? Disable Trigger All'

- Enable all triggers on all tables EXEC SP_MSFORETABLE 'ALTER TABLE? Enable Trigger All'

9. How to know which trigger is disabled? - Convert TRIGGER to binary in the STATUS field in the SYSObjects table, the 12th bit is 1 indicator, 0 means it allows the SELECT table name = Object_name (Parent_Obj), trigger Monographs = Name, State = Case Status & Power (2, 11) When 0 Then N 'Enable' Else N 'Disable' endfrom sysobjects where type = 'tr' [Thank happydreamer (small black) and ZJCXC (Zou Jian)] (Source: http://community.9cbs.net/expert/topic/3231/3231594.xml? Temp = .2487757)

10.

[From the future, the source is from 9CBS ZJCXC (Zou Jian))

转载请注明原文地址:https://www.9cbs.com/read-17943.html

New Post(0)