Weekday function returns the following values:(The following are: Constant value description)Vbsunday 1 SundayVbmonday 2 weeks AVbtuesday 3 Week IIVbwednesday 4 week ThreeVbthursday 5 ThuVbfriday 6 FridayVbsaturday 7 SaturdayWeekdayName functionDescription: Returns a String that represents the day of the week specified.Syntax: WeekdayName (Weekday, abbreviate, FirstDayOfWeek)Weekday: Must be selected. A numeric definition for the day of the week. The numeric definitions for each day depend on t
This article introduces an SQL statement about ORALCE to query all the dates of the current month. If you need it, you can check it.
1. query the months of the next 6 months:
The Code is as follows:
Copy code
SELECT to_char(add_months(SYSDATE, ROWNUM), 'yyyy-mm') FROM dualCONNECT BY ROWNUM
2. query all dates of the
SQL query case: convert a column to a row using UNION ALL.
After the conversion of rows and columns, you may encounter the need to replace columns.
Create table TestColRow (Name VARCHAR (10 ),East INT,South INT,West INT,North INT);
Insert into TestColRowVALUES ('zhang san', 1, 2, 3, 4 );
Insert into TestColRowVALUES ('Lee 4', 5, 6, 7, 8 );
Processing with UNION
That's all.
The stored procedure calls mup_geta (I erased the project-related names)
You can view objects dependent on mup_geta through the functions provided by sqlserver graphics manager.
The result is a bit confusing. I didn't list mup_getb (I used SQL Server 2005)
The solution is as follows:Method 1:Choose Database Management> right-click Database> tasks> Generate scripts> .....Export
-- SQL reads all fields in a specified data tableDeclare @ tablename nvarchar (250) -- Name of the data table in the current operationSet @ tablename = 'hzfa '-- specify the name of the data table to be queried (please change it to the name of the table in your own database)Declare @ columnname nvarchar (250) -- Name of the field currently queried in the cursorDeclare @ columndescription nvarchar (250) -- D
-- SQL reads all fields in a specified data tableDeclare @ TableName nvarchar (250) -- Name of the data table in the current operationSet @ TableName = 'hzfa '-- specify the name of the data table to be queried (please change it to the name of the table in your own database)Declare @ ColumnName nvarchar (250) -- Name of the field currently queried in the cursorDeclare @ ColumnDescription nvarchar (250) -- D
Label:Today let me back up all the databases on the Internet, jerked a look, hundreds of, the pit dad, had to find on the internet is not easy, did not think that there is really a note down, after use, haha ...Use master
declare @DbName varchar
DECLARE @BackSql varchar (+)
declare mycursor cursor
for SELECT [name] from sysdatabases
where [name] "not" (' Master ', ' model ', ' msdb ', ' tempdb ')
order BY [name]
Open MyCursor
fetch NEXT from MyCursor
Label:2010-01-26 sp_spaceused can view the space occupied by a table, but cannot view all the tables at once. Today, we studied this SP and wrote the following query: --Refresh system dataDBCC UPDATEUSAGE (0) with NO_INFOMSGS --8k per pageSelect name = Name,id,rows = Convert (char (one), rows),reserved = LTrim (str (reservedpages * 8.,15,0) + ' KB '),data = LTrim (str (pages * 8.,15,0) + ' KB '),index_size = LTrim (str ((usedpages-pages) * 8.,15,0) +
I only tested tables and stored procedures, and other objects were not actually tested,
Back up the database before use ,
I am not responsible for any errorsPai_^ .
1
/*
2
Brief: Change the owner of all objects in the database
3
Author: Wu erping
4
Date: 2005/12/19
5
*/
6
7
Declare
@ Owner
Varchar
(
255
)
8
Set
@ Owner
=
'
DBO
'
9
10
Declare
@ Obj
Loading editor...
How to write an SQL statement that queries the corresponding values of all Id fields in one table in another table?Multi-table join query:Select RBD. rbdid, RBD. productcode, P. productcnname, P. [standard], p. impression, PB. BrandName, cgdw. unitname, UN. unitname, RBD. buyingamount, RBD. unitpriceFrom pcs_requestbuydetails as RBDLeft join pm_products as P on RBD. productcode = P. produ
One SQL statement to query the first 10 records of all categories
For example, a class renewal table
Create course Table
Sid sname1 Language2. Mathematics3 English.......
Table B
Id Sid Fen name1 1 100 Zhang San2 1 89 Li Si3 1 95 Wang Wu4 2 89 Zhang San5 3 78 Wang Wu6 2 99 Wang Wu.....
Currently used
The top 10 accounts can be displayed.
Code highlighting produced by Actipro CodeHigh
--
Import all the Excel files in the folder to the SQL database. Each file is a separate table named by the file name.
--
By madgoat 2006-11-23
Create
Table
# T (fname
Varchar
(
260
), Depth
Int
, ISF
Bit
)
Insert
Into
# T
Exec
Master .. xp_dirtree
'
C: \ test \
'
,
1
,
1
Declare
TB
Cursor
For
Select
FN
=
'
C: \ te
-- In view of the fact that the field name is often required to obtain the list data of a data table. The following code is compiled.
-- Applicable scenarios: design or update select statements or insert statements for SQL stored procedures
-- The returned string format is similar to: "ID, begintime, endtime, addip, updateuser, updatetime, updateip"
-- Select name from syscolumns where id = object_id ('data table name ')-- Define a data table nameDec
-- SQL: obtain all the field types and precision scripts of the specified data table, and directly execute the following script.Select a. Name,Case A. PrecisionWhen 0 then
Case A. is_ansi_paddedWhen 1 thenConvert (nvarchar (15), B. Name + '(' + convert (nvarchar (10), a. max_length) + ')')When 0 thenB. NameEndElse
Case A. ScaleWhen 0 thenB. NameElseB. Name + '(' + convert (nvarchar (10), a. Precision) + '
Recently the company's database found that the data for the table was dropped, some data tables were recorded as 0, so I wanted to find out which data tables in the database were 0 to narrow the analysis, and use the following SQL statement:
code is as follows
copy code
CREATE TABLE #tmptb (tbnamesysname,tbrowsint , Tbreservedvarchar),tbdata varchar (a) , Tbindexsizevarchar (a), Tbunusedvarchar (a)) Insertinto
SQL Server traverses all tables in the database and the total number of statistical tables:
Code
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->1 declare @ tablename varchar (255 );
2 create table # getrecordingtemptable ([ID] [int] Identity (1,1) not null, [tablename] varchar (255) not null, [recordingcount] INT );
3 declare table_cursor cursor for select
Tags: SELECT * from Information_schema.columns WHERE table_name= ' account ' SELECT [case] A.colorder=1 then d.name Else ' ' End ' as table name,--if the table name is the same, return the empty a.colorder as field ordinal, a.name as field name, (case when ColumnProperty (A.id,a.name, '
Isidentity ') =1 then ' √ ' else ' end as identifier (case when (SELECT count (*) from sysobjects--query primary key Where (the name in (the SELECT name from sysindexes WHERE (id = a).
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.