Does anyone know a function in SQL or how I can get the amount of characters of a field?
I have a column named NU_IPS wich contains data varchar type, that has a % symbol at the end, like 9.7% and so on... But in original table it can't be like this (it has to bem float type), I just want the number content, like this 9.7 For that I need in DTS put a query that convert it. That's why I need a function or something that can get the quantity of characters of each field.
So, It would be someting like this...
select substring(convert(varchar(getSizeField() - 1), nu_ipi), 1, 4) from dbo.t_STAGEAREACHAIR
It would cut always the last caracter, wich is '%'...
Any clues?
All posts are welcome, thanks.Look up the Len() - function ...|||Thanks Nephilim!
But why can't I put this function in the convert if it returns a int type?
I guess it can't process each field at time, 'cause we can admit there's a table in convert varchar paremeter, it's obvious.
Like:
select substring(convert(varchar(SELECT len(nu_ipi) - 1 FROM dbo.t_STAGEAREACHAIR), nu_ipi), 1, 4) from dbo.t_STAGEAREACHAIR
I've tried putting an IF statment...
Like:
if ((select len(nu_ipi) - 1 from dbo.t_STAGEAREACHAIR) = 1)
begin
select substring(convert(varchar(1), nu_ipi), 1, 4) from dbo.t_STAGEAREACHAIR
end
But it returns more than 1 value though.
Have you an idea how I can do it?
Thanks|||First of all, there really is no need to put a subselect in the select you posted :
select substring(convert(varchar(SELECT len(nu_ipi) - 1 FROM dbo.t_STAGEAREACHAIR), nu_ipi), 1, 4) from dbo.t_STAGEAREACHAIR
I think you are looking for something like this
select substring(convert(Varchar(10), NU_IPS), 1, len(convert(Varchar(10), NU_IPS)) -1 from dbo.t_STAGEAREACHAIR
however I'm not exactly certain I've understood your problem fully...|||maybe i don't understand it fully either, but NU-IPS is already a varchar, so...
select left(NU_IPS,len(NU_IPS)-1) ...or alternatively
select replace(NU_IPS,'%','') ...|||r937 and Nephilim
I think You got it, that's what I wanted.
It works...
Really thanks!
Juliane
Showing posts with label contains. Show all posts
Showing posts with label contains. Show all posts
Monday, March 19, 2012
Friday, February 24, 2012
how i can make script Database with Data?
hi
i am working on Windows 2000 Advanced Server + SP4 and SQL2000 Enterprise +
SP4.
i have database contains Tables, and i want make script to build Tables on
other Database,
but i need this script include Data in Tables too, i can make that ? and
how?
thanks
--
Tarek M. Sialahi,
Tark Siala wrote:
> hi
> i am working on Windows 2000 Advanced Server + SP4 and SQL2000
> Enterprise + SP4.
> i have database contains Tables, and i want make script to build
> Tables on other Database,
> but i need this script include Data in Tables too, i can make that ?
> and how?
> thanks
you can have a look at a free prj of mine, at the link following my sign.,
DbaMgr2k, which include an "INSERT INTO" script generation feature at table
level...
--
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.bizhttp://italy.mvps.org
DbaMgr2k ver 0.19.0 - DbaMgr ver 0.63.0 and further SQL Tools
-- remove DMO to reply|||Try www.sqlscripter.com to generate data scripts. It's free.
"Tark Siala" wrote:
> hi
> i am working on Windows 2000 Advanced Server + SP4 and SQL2000 Enterprise
+
> SP4.
> i have database contains Tables, and i want make script to build Tables on
> other Database,
> but i need this script include Data in Tables too, i can make that ? and
> how?
> thanks
> --
> Tarek M. Siala
>
>
i am working on Windows 2000 Advanced Server + SP4 and SQL2000 Enterprise +
SP4.
i have database contains Tables, and i want make script to build Tables on
other Database,
but i need this script include Data in Tables too, i can make that ? and
how?
thanks
--
Tarek M. Sialahi,
Tark Siala wrote:
> hi
> i am working on Windows 2000 Advanced Server + SP4 and SQL2000
> Enterprise + SP4.
> i have database contains Tables, and i want make script to build
> Tables on other Database,
> but i need this script include Data in Tables too, i can make that ?
> and how?
> thanks
you can have a look at a free prj of mine, at the link following my sign.,
DbaMgr2k, which include an "INSERT INTO" script generation feature at table
level...
--
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.bizhttp://italy.mvps.org
DbaMgr2k ver 0.19.0 - DbaMgr ver 0.63.0 and further SQL Tools
-- remove DMO to reply|||Try www.sqlscripter.com to generate data scripts. It's free.
"Tark Siala" wrote:
> hi
> i am working on Windows 2000 Advanced Server + SP4 and SQL2000 Enterprise
+
> SP4.
> i have database contains Tables, and i want make script to build Tables on
> other Database,
> but i need this script include Data in Tables too, i can make that ? and
> how?
> thanks
> --
> Tarek M. Siala
>
>
how i can make script Database with Data?
hi
i am working on Windows 2000 Advanced Server + SP4 and SQL2000 Enterprise +
SP4.
i have database contains Tables, and i want make script to build Tables on
other Database,
but i need this script include Data in Tables too, i can make that ? and
how?
thanks
--
Tarek M. Sialahi,
Tark Siala wrote:
> hi
> i am working on Windows 2000 Advanced Server + SP4 and SQL2000
> Enterprise + SP4.
> i have database contains Tables, and i want make script to build
> Tables on other Database,
> but i need this script include Data in Tables too, i can make that ?
> and how?
> thanks
you can have a look at a free prj of mine, at the link following my sign.,
DbaMgr2k, which include an "INSERT INTO" script generation feature at table
level...
--
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.bizhttp://italy.mvps.org
DbaMgr2k ver 0.19.0 - DbaMgr ver 0.63.0 and further SQL Tools
-- remove DMO to reply
i am working on Windows 2000 Advanced Server + SP4 and SQL2000 Enterprise +
SP4.
i have database contains Tables, and i want make script to build Tables on
other Database,
but i need this script include Data in Tables too, i can make that ? and
how?
thanks
--
Tarek M. Sialahi,
Tark Siala wrote:
> hi
> i am working on Windows 2000 Advanced Server + SP4 and SQL2000
> Enterprise + SP4.
> i have database contains Tables, and i want make script to build
> Tables on other Database,
> but i need this script include Data in Tables too, i can make that ?
> and how?
> thanks
you can have a look at a free prj of mine, at the link following my sign.,
DbaMgr2k, which include an "INSERT INTO" script generation feature at table
level...
--
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.bizhttp://italy.mvps.org
DbaMgr2k ver 0.19.0 - DbaMgr ver 0.63.0 and further SQL Tools
-- remove DMO to reply
how i can make script Database with Data?
hi
i am working on Windows 2000 Advanced Server + SP4 and SQL2000 Enterprise +
SP4.
i have database contains Tables, and i want make script to build Tables on
other Database,
but i need this script include Data in Tables too, i can make that ? and
how?
thanks
--
Tarek M. Sialahi,
Tark Siala wrote:
> hi
> i am working on Windows 2000 Advanced Server + SP4 and SQL2000
> Enterprise + SP4.
> i have database contains Tables, and i want make script to build
> Tables on other Database,
> but i need this script include Data in Tables too, i can make that ?
> and how?
> thanks
you can have a look at a free prj of mine, at the link following my sign.,
DbaMgr2k, which include an "INSERT INTO" script generation feature at table
level...
--
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.bizhttp://italy.mvps.org
DbaMgr2k ver 0.19.0 - DbaMgr ver 0.63.0 and further SQL Tools
-- remove DMO to reply
i am working on Windows 2000 Advanced Server + SP4 and SQL2000 Enterprise +
SP4.
i have database contains Tables, and i want make script to build Tables on
other Database,
but i need this script include Data in Tables too, i can make that ? and
how?
thanks
--
Tarek M. Sialahi,
Tark Siala wrote:
> hi
> i am working on Windows 2000 Advanced Server + SP4 and SQL2000
> Enterprise + SP4.
> i have database contains Tables, and i want make script to build
> Tables on other Database,
> but i need this script include Data in Tables too, i can make that ?
> and how?
> thanks
you can have a look at a free prj of mine, at the link following my sign.,
DbaMgr2k, which include an "INSERT INTO" script generation feature at table
level...
--
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.bizhttp://italy.mvps.org
DbaMgr2k ver 0.19.0 - DbaMgr ver 0.63.0 and further SQL Tools
-- remove DMO to reply
how i can make script Database with Data?
hi
i am working on Windows 2000 Advanced Server + SP4 and SQL2000 Enterprise +
SP4.
i have database contains Tables, and i want make script to build Tables on
other Database,
but i need this script include Data in Tables too, i can make that ? and
how?
thanks
--
Tarek M. Sialahi,
Tark Siala wrote:
> hi
> i am working on Windows 2000 Advanced Server + SP4 and SQL2000
> Enterprise + SP4.
> i have database contains Tables, and i want make script to build
> Tables on other Database,
> but i need this script include Data in Tables too, i can make that ?
> and how?
> thanks
you can have a look at a free prj of mine, at the link following my sign.,
DbaMgr2k, which include an "INSERT INTO" script generation feature at table
level...
--
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.bizhttp://italy.mvps.org
DbaMgr2k ver 0.19.0 - DbaMgr ver 0.63.0 and further SQL Tools
-- remove DMO to reply
i am working on Windows 2000 Advanced Server + SP4 and SQL2000 Enterprise +
SP4.
i have database contains Tables, and i want make script to build Tables on
other Database,
but i need this script include Data in Tables too, i can make that ? and
how?
thanks
--
Tarek M. Sialahi,
Tark Siala wrote:
> hi
> i am working on Windows 2000 Advanced Server + SP4 and SQL2000
> Enterprise + SP4.
> i have database contains Tables, and i want make script to build
> Tables on other Database,
> but i need this script include Data in Tables too, i can make that ?
> and how?
> thanks
you can have a look at a free prj of mine, at the link following my sign.,
DbaMgr2k, which include an "INSERT INTO" script generation feature at table
level...
--
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.bizhttp://italy.mvps.org
DbaMgr2k ver 0.19.0 - DbaMgr ver 0.63.0 and further SQL Tools
-- remove DMO to reply
Subscribe to:
Posts (Atom)