Results 1 to 7 of 7

Thread: [RESOLVED] Why is there different function in SQL Server and SQL management studio (SSMS) 2017 ?

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2018
    Location
    France, North
    Posts
    61

    Resolved [RESOLVED] Why is there different function in SQL Server and SQL management studio (SSMS) 2017 ?

    Hi, I think I understood the difference between SQL Server and SSMS (at least, I have an idea).

    I'm using SSMS and I wanted to compare two dates. I try to use functions like "NOW()" ; "DATE()" but it doesn't work on SSMS.

    Finally I succeed to do what I wanted using DATEDIFF() :
    SQL Code:
    1. Select datediff(DAY, @Year-@Month-@Day, 2015-11-11)

    But I was wondering why we can't use SQL Server's function in SSMS, is there someone who could enlighten me ?

  2. #2
    Frenzied Member gibra's Avatar
    Join Date
    Oct 2009
    Location
    ITALY
    Posts
    1,696

    Re: Why is there different function in SQL Server and SQL management studio (SSMS) 20

    Now() and Date() aren't SQL Server functions

    Date and Time Data Types and Functions (Transact-SQL) - SQL Server | Microsoft Docs
    https://docs.microsoft.com/en-us/sql...ql-server-2017

  3. #3
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,040

    Re: Why is there different function in SQL Server and SQL management studio (SSMS) 20

    Quote Originally Posted by Macronaute View Post
    But I was wondering why we can't use SQL Server's function in SSMS
    You can. If what you did didn't work then you did it wrong. If you don't tell us what you actually did and what actually happened, we can only guess at why it didn't work.

    You do know that the "SS" in SSMS stands for SQL Server, right? SQL Server is a database system and SSMS is a management tool for that database system. Pretty much any SQL code that SQL Server supports can be used in SSMS. Where else would you use it if not there? There is also a commandline interface (SQLCMD) that may support some obscure things that can't be used in SSMS but anything that you would want to use won't be problem. You just have to use them properly.

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,040

    Re: Why is there different function in SQL Server and SQL management studio (SSMS) 20

    Quote Originally Posted by gibra View Post
    Now() and Date() aren't SQL Server functions
    Hah, I didn't even pay close enough attention to register that. I'm guessing what was actually happening was that the attempt was actually to use VB or perhaps Jet (Access) SQL functions, with the latter having been influenced by VBA.

  5. #5
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,040

    Re: Why is there different function in SQL Server and SQL management studio (SSMS) 20

    Maybe the issue here is that you don't understand exactly what SQL is. SQL is a language - Structured Query Language - that is used by just about every database. SQL Server is just one of those databases, with others including Oracle, MySQL, PostgreSQL, SQLite, Jet/Access, etc. As you can see, having "SQL" in the name of a database that uses SQL for queries is quite common. Each database will generally have its own flavour of SQL, which means that it will implement much of the SQL standard but not necessarily all, and some of it in its own way, plus it may have certain features of its own that extend the standard. The flavour of SQL used by SQL Server is T-SQL, with the T standing for "Transact". It originated with Sybase, which SQL Server was originally based on.

  6. #6

    Thread Starter
    Member
    Join Date
    Aug 2018
    Location
    France, North
    Posts
    61

    Re: Why is there different function in SQL Server and SQL management studio (SSMS) 20

    Thank you for your reply,

    Your explanation of the SQL meaning was very interesting, it help me to understand why some functions find on internet do not work as well as expected, I didn't pay attention to what database each function was attached.

    I will try to improve myself in T-SQL (No big deal by the way).

    Thank you again, have a nice day !

  7. #7
    Frenzied Member
    Join Date
    Dec 2014
    Location
    VB6 dinosaur land
    Posts
    1,191

    Re: Why is there different function in SQL Server and SQL management studio (SSMS) 20

    Quote Originally Posted by Macronaute View Post
    I will try to improve myself in T-SQL (No big deal by the way).
    Until the end of THIS month, there is a decent FREE course from Microsoft on T-SQL.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width