Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to extract four numbers frome a series numbers

Author  Topic 

Warmar
Starting Member

7 Posts

Posted - 2013-07-02 : 04:07:00
Hi

This is my first post on this site and i realy hope you could help me. I need a sql code that take this series of numbers

66425940110 to the four last four numbers 0110. I wrote this code Right$( str , num )but is dident take the first 0 in. The result was 110 which isent good enought. I need it so say 0110. In exampels with no 0 the result is what i whant for exampel

66425981565 which makes it 1565. This is how i whant it to be even in numberseries with 0.

This sql code is for a mapmaking program cald mapinfo.

/Warmar

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-07-02 : 04:13:42
in SQL Server you can do like this.

SELECT RIGHT(CAST(YourColumn AS varchar(20)),4) AS YourValue FROM YourTable


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

Warmar
Starting Member

7 Posts

Posted - 2013-07-02 : 04:27:23
i tryed but it dident work.
Im kind of new on this. Could you write what exact to write?
I got some some notes frome i co worker that is on semester now which goes like this.

"Mid$(mycolumn),X4) Is that right? There is something wrong with is beacuse it dosent work for me :S
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-07-02 : 04:29:10
quote:
Originally posted by Warmar

i tryed but it dident work.
Im kind of new on this. Could you write what exact to write?
I got some some notes frome i co worker that is on semester now which goes like this.

"Mid$(mycolumn),X4) Is that right? There is something wrong with is beacuse it dosent work for me :S


I'm not sure whether you're using SQL Server. The syntaxes of code you posted so far is not T-SQL. So please tell us which RDBMS you're using

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

Warmar
Starting Member

7 Posts

Posted - 2013-07-02 : 04:37:03
Im not sure. But i think it use some kind of simplear version of sql. At least that what i got out frome http://www.vldb.org/conf/1998/p704.pdf
Go to Top of Page

Warmar
Starting Member

7 Posts

Posted - 2013-07-02 : 04:39:12
Since the program isent only a database program. It is mainly a mapmaking program which connect databse info to a visual map
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-07-02 : 04:43:10
quote:
Originally posted by Warmar

Since the program isent only a database program. It is mainly a mapmaking program which connect databse info to a visual map


Then you may be better off posting it in some application spefic forum for mapinfo

This is a SQL Server forum and we deal with only database specific problems in SQL Server.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

Warmar
Starting Member

7 Posts

Posted - 2013-07-02 : 04:43:36
Okey. Thanks for help !
Go to Top of Page

Warmar
Starting Member

7 Posts

Posted - 2013-07-02 : 05:09:46
I think i know what you whanted to know now.

"The MapInfo SQL Language is based on the SQL-3 and SQL/MM standards. String literals must be enclosed in single quotation marks ('example') while identifiers (column names, table names, aliases, etc) should be enclosed in double quotation marks ("example identifier") if necessary. Identifiers only need to be quoted if the parsing logic is unable to correctly parse the identifier. This would include identifiers that have spaces in their names or other special characters.

Does is help?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-07-02 : 05:25:23
quote:
Originally posted by Warmar

I think i know what you whanted to know now.

"The MapInfo SQL Language is based on the SQL-3 and SQL/MM standards. String literals must be enclosed in single quotation marks ('example') while identifiers (column names, table names, aliases, etc) should be enclosed in double quotation marks ("example identifier") if necessary. Identifiers only need to be quoted if the parsing logic is unable to correctly parse the identifier. This would include identifiers that have spaces in their names or other special characters.

Does is help?



Not much
As i still dont know what all are string functions it will support, its syntax etc

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

Warmar
Starting Member

7 Posts

Posted - 2013-07-02 : 05:29:10
http://reference.mapinfo.com/software/mapinfo_developer/english/1_0/misql/introduction/commands.html
is the source
Go to Top of Page

chbala85
Starting Member

49 Posts

Posted - 2013-07-02 : 06:20:51
find below

declare @Column bigint
set @Column=3728990030072

SELECT RIGHT(CAST(@Column AS varchar(20)),4)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-07-02 : 06:22:55
quote:
Originally posted by chbala85

find below

declare @Column bigint
set @Column=3728990030072

SELECT RIGHT(CAST(@Column AS varchar(20)),4)


how is this different from what I posted 2 hours ago?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -