One, SQL Server date-time functionsDate and time functions in SQL Server1. Current system date, timeSelect GETDATE ()2. DateAdd returns a new datetime value based on adding a period of time to the specified dateExample: Add 2 days to the dateSelect DATEADD (day,2, ' 2004-10-15 ')--return: 2004-10-17 00:00:00.0003. DateDiff returns the number of date and time boundaries across two specified dates.Select Date
Concatenate multiple rows of records in the same column in Oracle into a string [SQL] -- raw data -- a 111 -- B 222 -- a 333 -- a 444 -- B 555 -- final result -- a 111*333*444 SELECT L4.L _ TIME, MAX (SUBSTR (L4. group CONTENT, 2) final field value FROM (SELECT L3.L _ TIME, SYS_CONNECT_BY_PATH (L3.L _ CONTENT ,'*') AS group content from (SELECT L2.L _ TIME, L2.L _ CONTENT, L2.L _ TIME | L2. group id as grou
Scenario: Update A field value with Update, which is made up of another field and a string in the same table
SQL statement:
The code is as follows
Copy Code
Update ' tablename ' Set Field1=concat (' tablename '. Field2, "str");
SQL Server connection string Encryption
Use components provided by ASP. NET
-Wordpress Encryption
-PDF decryption
{0} Name of the node to be encrypted
{1} project path
C: \ windows \ Micrsoft. Net \ framework \ versionnumber \ aspnet_regiis.exe-FFE "connectionstrings" "D: \ website2"
Note: Encryption can only be performed on the local machine through the local configuration; in ASP. NETProgramWill be
In general, we will configure the relevant connection string in the web. config file, which is recorded here for future use.
1. Commonly Used
A: SQL Server Authentication connection stringView code
1 2 3 providername = "system. Data. sqlclient"> 4
B. Windows Authentication connection stringView code
1 2 3 providername = "system. Data. sqlclient"> 4
In addition, you can use
Code: see the above.
Method
Recently, I used an XML file to send a stream file to insert it into the database. It took a long time to locate the bug because of intermediate encryption, transcoding, and a bunch of operations, the final reason is that the table creation brothers do not know how to do this. Some fields are followed by character set definitions.
Character Set Latin1
As a result
Java. SQL. sqlexception: incorrect strin
Tags: logs convert weight made with int span app DivSQL Server Profiler caught a lot of code in the job, applicationname similar to Sqlagent-tsql JobStep (Job 0x94b9b5c016e8d94fb50898c868314d08:st EP 1) Such a Need to convert the binary name in the job into job_id The conversion is done in the following ways: Declare @JobID uniqueidentifier
SELECT @JobID = 0x94b9b5c016e8d94fb50898c868314d08
PRINT 'My JobID is' + Convert(Char(255),@JobID)
Select * fromMsdb.dbo.sysjobswherejob_id=Convert(Char(
Tags: sql join lemp end character size routing employee LinCase is left (t5.name,2) = ' substring ' and then ' (t5.name,9,2) Else substring (t5.name,7,2) End GD Intercept pre-1~10 digits ac17072408 Select substring (name,0,11) from Profin_application; name=ac1707240801 Select substring (name,0,11) from Profin_application;Select Left (name,10) from Profin_application; Select T1.name, Timeadd (' Hour ', 8,t1.date), T3.name_template, left (t3.name_t
Tags: create function Fn_find (@find varchar (8000), @str varchar (8000), @n smallint) ret Urns int as BEGIN if @n SQL Server finds the location of the specified string
How SQL Server, MySQL gets the connection stringSteps:First, create a new text document Xxx.txt, modify the file type to. udlSecond, open the document, in the "provide data" to find the corresponding services.Third, select the required database in the connection and fill in the relevant information.Iv. Test Connection, if successful then skip to the next step, failure is the user information error, re-modify.Change the xxx.udl suffix name to txt and o
When connecting to a database with a. UDL, select Allow Persist Security info=true when saving passwords, otherwise falseThe Persist Security Info property is meant to indicate whether or not to save secure information, in fact, it can be simply understood as "whether ADO saves password information after a successful database connection",True means save, false means no saveThe default for ADO is False, not tested, according to the referenceThis can be verified by the ConnectString property of th
Label:SQL Create function Database name--programmability---table-valued functions Right-click to create a "multi-statement table-valued Function" CREATE FUNCTION [dbo].[Fun_splitstr](@str VARCHAR(MAX))
RETURNS @temp TABLE(IDINT)
as
BEGIN
DECLARE @ch as VARCHAR( -)
SET @str+=','
while(@str"')
BEGIN
SET @ch = Left(@str,CHARINDEX(',',@str,1)-1)
IF @ch>0
INSERT @temp VALUES(@ch)
SET @str=STUFF(@str,1,CHARINDEX(',',@str,1),"')
END
RETURN
END
Can the intercepted string be directly treated as the where condition in the SQL statement, such as select nbsp; 'id' nbsp; from nbsp; 'table' nbsp; where nbsp; left ('flag', 1) = 1; I have a string of flag IDs used to indicate various attributes of the product. nbsp; can a 10-bit SQL statement directly use the t
Label:Delete the table containing the specified stringCREATE PROCEDURE Sys_deletetablebytablename (@bianliang varchar (100))AsBeginDECLARE @biao varchar (+), @sql varchar (1000)Set @sql = '% ' [email protected]+ '% 'Declare c cursor for select name from sysobjects where type= ' u ' and name @sqlSet @sql = ' drop table 'Open CFetch C into @biaoWhile @ @fetch_statu
Basic SQL string operations
From: http://hi.baidu.com/15960278709/blog/item/bd3507ddf14af3ea76c63805.html
-- ======================================================= ======================================
-- Truncates a string from a character and inserts another string hereSelect stuff ('hello, world! ', 4, 4,' *
value * * * *--===================================================================================--============= ======================== Digital Operations Summary ==================================--returns the largest integer of a specified numberSelectFloor123456.1234) --return value 123456--returns the smallest number without a decimal part and not less than the value of its argument. If the argument is an empty sequence, an empty sequence is returnedSelectCeiling123.010) --back to 1
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.