Skip to primary content
Skip to secondary content

Spearcross

All About Programming, Piece of My Mind, And Anything

Spearcross

Main menu

  • Home
  • About

Tag Archives: SQL Query

SQL Query Get Date Only For The Date Part

Posted on June 9, 2013 by silentcross
Reply

Here’s some example to get the date part in sql with datetime data type :

1
DATEADD(dd, 0, DATEDIFF(dd, 0, [yourdate]))

or

1
CONVERT(date, [yourdate])
Posted in Programming | Tagged MS SQL, SQL Query, T-SQL | Leave a reply

SQL Query Get 2nd Row Data

Posted on June 7, 2013 by silentcross
Reply

Here’s example to get 2nd row data with sql query

1
2
3
4
5
6
7
    ;WITH YourCTE AS
    (
    SELECT TOP 2
        *, ROW_NUMBER() OVER(ORDER BY [YourColumn]) AS RowNumber
        FROM [YourTable]
    )
    SELECT * FROM YourCTE WHERE RowNumber=2
Posted in Programming | Tagged SQL, SQL Query, T-SQL | Leave a reply

Convert Int to String SQL Query

Posted on January 2, 2013 by silentcross
Reply

To convert int or any number to string in sql query we can use :

1
CAST([datatoconvert] as VARCHAR(50)) as exp1

Or

1
CONVERT(VARCHAR(50), [datatoconvert]) as exp1
Posted in Programming | Tagged SQL Query | Leave a reply

SQL Query For Reset Table Identity

Posted on August 3, 2012 by silentcross
Reply

This is SQL Query for resetting Table Indentity :

1
DBCC CHECKIDENT ([Table_Name], reseed, Reset_Number_To)

place your Table Name in [Table_Name] and replace Reset_Number_To with number you want to start the identity for the next record, for example if you want your identity number start from 1, you replace Reset_Number_To with 0

Posted in Programming | Tagged Reseed, SQL, SQL Query | Leave a reply

MSSQL Query Two Digit Year, Month, and Date

Posted on March 26, 2011 by silentcross
2

Here’s some SQL Query to get Two Digit Year, Month and Date

Year :

1
print right(year(getdate()), 2)

result :
11

Month :

1
print right('0' + month(getdate()), 2)

result :
03

Date :

1
print right('0' + day(getdate()), 2)

result :
26

Posted in Programming, Windows | Tagged MSSQL, SQL Query | 2 Replies

Recent Posts

  • Mikrotik Script For auto reconnect PPPOE to get Public IP
  • Change to another Hosting & 2020 Updates
  • DDNS Cloudflare API
  • Change Hosting in 2018
  • MTCNA + MTCRE Accomplished

Categories

  • ASP.NET (2)
  • C (1)
  • Event (3)
  • FreeWare (2)
  • IIS (5)
  • Intro (1)
  • Linux (3)
  • News (3)
  • PHP (4)
  • Piece of My Mind (18)
  • Programming (16)
  • Uncategorized (8)
  • Windows (12)

Tags

  • .NET
  • ASP.NET
  • Canon IP4870
  • Cloudflare
  • Computer
  • C Programming
  • DDR1
  • DDR2
  • Decimal
  • Eggdrop tcl script
  • Event
  • Festival Komputer Indonesia
  • FKI
  • Gateway
  • Hosting
  • Hotmail
  • HTTPS
  • IIS 6
  • IIS ASP.NET
  • IndoComtech
  • Ink
  • Linux
  • Local Network
  • Memory
  • Microsoft
  • MRTG
  • MSSQL
  • MS SQL
  • PHP
  • PHP Windows IIS5
  • Proxy
  • Reset
  • Restter
  • Roman
  • SODIMM
  • SQL
  • SQL Query
  • Squid
  • T-SQL
  • Tank
  • uBuntu
  • Windows
  • Windows 7
  • Windows Server 2003
  • Wordpress

Calendar

September 2023
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  
« Jul    

Blogroll

  • Cybernations
  • Kaskus
  • Namecheap
  • Support Forum
  • Themes
  • WordPress Blog
  • WordPress Planet

Tags

  • .NET
  • ASP.NET
  • Canon IP4870
  • Cloudflare
  • Computer
  • C Programming
  • DDR1
  • DDR2
  • Decimal
  • Eggdrop tcl script
  • Event
  • Festival Komputer Indonesia
  • FKI
  • Gateway
  • Hosting
  • Hotmail
  • HTTPS
  • IIS 6
  • IIS ASP.NET
  • IndoComtech
  • Ink
  • Linux
  • Local Network
  • Memory
  • Microsoft
  • MRTG
  • MSSQL
  • MS SQL
  • PHP
  • PHP Windows IIS5
  • Proxy
  • Reset
  • Restter
  • Roman
  • SODIMM
  • SQL
  • SQL Query
  • Squid
  • T-SQL
  • Tank
  • uBuntu
  • Windows
  • Windows 7
  • Windows Server 2003
  • Wordpress
Proudly powered by WordPress