Is it possible to check whether a column (define as char
type) value is numeric using something like
Select * From table_name Where Field1 is numeric ?
Thanks,
BenYou can use the ISNUMERIC function for this:
WHERE ISNUMERIC(colname) = 1
Note, however that this returns 1 if the data can be converted to int,
float, money etc. So things like "E" and "," in the string will pass the
test. If you post what you mean precisely by "numeric" we can possibly give
a better suggestion.
--
Tibor Karaszi, SQL Server MVP
Archive at:
http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
"Ben" <bluebells88@.yahoo.com> wrote in message
news:2eb201c3a9c4$176cb430$a601280a@.phx.gbl...
> Is it possible to check whether a column (define as char
> type) value is numeric using something like
> Select * From table_name Where Field1 is numeric ?
> Thanks,
> Ben|||Thank your very much for your answer. This one works fine
for my case :)
I've another question: Is it possible to determine if the
column value is NOT alphabet. (using ASCII ? It seems
impossible to me.)
Thanks,
Ben
>--Original Message--
>You can use the ISNUMERIC function for this:
>WHERE ISNUMERIC(colname) = 1
>Note, however that this returns 1 if the data can be
converted to int,
>float, money etc. So things like "E" and "," in the
string will pass the
>test. If you post what you mean precisely by "numeric"
we can possibly give
>a better suggestion.
>--
>Tibor Karaszi, SQL Server MVP
>Archive at:
>http://groups.google.com/groups?
oi=djq&as_ugroup=microsoft.public.sqlserver
>
>"Ben" <bluebells88@.yahoo.com> wrote in message
>news:2eb201c3a9c4$176cb430$a601280a@.phx.gbl...
>> Is it possible to check whether a column (define as
char
>> type) value is numeric using something like
>> Select * From table_name Where Field1 is numeric ?
>> Thanks,
>> Ben
>
>.
>
Showing posts with label define. Show all posts
Showing posts with label define. Show all posts
Tuesday, March 20, 2012
Sunday, March 11, 2012
check constraint on input parameter
New to SQL server 2000 and wondering if it's possible to define a check
constraint on an input parameter
(stored procedure).
My input parameter(defined as smallint) should only accept the values 0, 1
or 2.
Would appreciate any help.
Message posted via http://www.webservertalk.comI dont think it is possible. But what you can do instead is the have a
check in the stored procedure and raise an error if the value passed is
not one of the expected values.|||you'd have to either
1) raise an error at the top of the procedure
2) default to 0 for <0 or 2 for >2
e.g.
create procedure myproc @.input1 smallint as
if @.input1 not between 0 and 2
begin
raiserror('Procedure myproc requires parameter @.input1 to be between
0 and 2', 16, 1)
return -1
end
...
or
create procedure myproc @.input1 smallint as
select @.input1 = case when @.input1<0 then 0 when @.input1>2 then 2 else
@.input1 end
...
Cismail via webservertalk.com wrote:
> New to SQL server 2000 and wondering if it's possible to define a check
> constraint on an input parameter
> (stored procedure).
> My input parameter(defined as smallint) should only accept the values 0,
1
> or 2.
> Would appreciate any help.
>|||That's what I thought.
Thanks for your help.
SQL novice wrote:
>I dont think it is possible. But what you can do instead is the have a
>check in the stored procedure and raise an error if the value passed is
>not one of the expected values.
Message posted via webservertalk.com
http://www.webservertalk.com/Uwe/Forum...amming/200511/1
constraint on an input parameter
(stored procedure).
My input parameter(defined as smallint) should only accept the values 0, 1
or 2.
Would appreciate any help.
Message posted via http://www.webservertalk.comI dont think it is possible. But what you can do instead is the have a
check in the stored procedure and raise an error if the value passed is
not one of the expected values.|||you'd have to either
1) raise an error at the top of the procedure
2) default to 0 for <0 or 2 for >2
e.g.
create procedure myproc @.input1 smallint as
if @.input1 not between 0 and 2
begin
raiserror('Procedure myproc requires parameter @.input1 to be between
0 and 2', 16, 1)
return -1
end
...
or
create procedure myproc @.input1 smallint as
select @.input1 = case when @.input1<0 then 0 when @.input1>2 then 2 else
@.input1 end
...
Cismail via webservertalk.com wrote:
> New to SQL server 2000 and wondering if it's possible to define a check
> constraint on an input parameter
> (stored procedure).
> My input parameter(defined as smallint) should only accept the values 0,
1
> or 2.
> Would appreciate any help.
>|||That's what I thought.
Thanks for your help.
SQL novice wrote:
>I dont think it is possible. But what you can do instead is the have a
>check in the stored procedure and raise an error if the value passed is
>not one of the expected values.
Message posted via webservertalk.com
http://www.webservertalk.com/Uwe/Forum...amming/200511/1
Sunday, February 19, 2012
Chart grouped by date
Hi,
I´m trying to define a column chart grouped by date and I can´t find the
proper way.
What I need is to show every month from one date to another even if there´s
no data in a specific month.
I also need to sum data from different recordsets grouping by month + year.
For example:
MY DATASETS
ds1:
date1 > Total1
1/1/2007 > 20
9/1/2007 > 15
1/3/2007 > 10
1/4/2007 > 40
1/5/2007 > 25
ds2:
date2 > Total2
1/2/2007 > 2
9/2/2007 > 1
1/4/2007 > 5
1/4/2007 > 4
1/6/2007 > 3
PARAMETERS:
StartDate: 1/1/2007
EndDate: 31/12/2007
MY CHART SHOULD SHOW:
January 2007 > 35
February 2007 > 3
March 2007 > 10
April 2007 > 49
May 2007 > 25
June 2007 > 3
July 2007 > 0
August 2007 > 0
September 2007 > 0
October 2007 > 0
November 2007 > 0
December 2007 > 0
How can I do this?
What must I put in the chart group?, is there any "UNION" option in groups?
(i.e. month(Fields!Date.Value, "ds1") & " " & year(Fields!Date.Value, "ds1")
UNION month(Fields!Date.Value, "ds2") & " " & year(Fields!Date.Value, "ds2")
How do I set the values?
Any help will be apreciated.
Thanks,
MónicaOn Nov 5, 12:48 pm, "M=F3nica" <monica.d...@.augure.com> wrote:
> Hi,
> I=B4m trying to define a column chart grouped by date and I can=B4t find =the
> proper way.
> What I need is to show every month from one date to another even if there==B4s
> no data in a specific month.
> I also need to sum data from different recordsets grouping by month + yea=r=2E
> For example:
> MY DATASETS
> ds1:
> date1 > Total1
> 1/1/2007 > 20
> 9/1/2007 > 15
> 1/3/2007 > 10
> 1/4/2007 > 40
> 1/5/2007 > 25
> ds2:
> date2 > Total2
> 1/2/2007 > 2
> 9/2/2007 > 1
> 1/4/2007 > 5
> 1/4/2007 > 4
> 1/6/2007 > 3
> PARAMETERS:
> StartDate: 1/1/2007
> EndDate: 31/12/2007
> MY CHART SHOULD SHOW:
> January 2007 > 35
> February 2007 > 3
> March 2007 > 10
> April 2007 > 49
> May 2007 > 25
> June 2007 > 3
> July 2007 > 0
> August 2007 > 0
> September 2007 > 0
> October 2007 > 0
> November 2007 > 0
> December 2007 > 0
> How can I do this?
> What must I put in the chart group?, is there any "UNION" option in group=s?
> (i.e. month(Fields!Date.Value, "ds1") & " " & year(Fields!Date.Value, "ds=1")
> UNION month(Fields!Date.Value, "ds2") & " " & year(Fields!Date.Value, "ds=2")
> How do I set the values?
> Any help will be apreciated.
> Thanks,
> M=F3nica
Unfortunately, you cannot Union two datasets together (wish you
could). The data has to be aggregated before it is delivered to the
report. I've had suggestions to me of (1) Custom DataSets, (2)
Analysis Server joined Cubes, (3) SELECT from a SQL Server containing
Linked Servers to the two datasets, then UNION on the server and
return a single dataset to SSRS.
Your second issue, Group By Month, create your Chart based off of
DataSet 1, add the DATE1 as a Category, then go to Chart Properties,
Data Tab, select the Category group, Edit, and change the Group
Expression to something like:
=3DDateAdd( d, 1-Day(Fields!date1.Value), Fields!date1.Value)
then change the Label to
=3DFormat( Fields!date1.Value, "MMMM yyyy" )
and change the Sorting to
=3DDateAdd( d, 1-Day(Fields!date1.Value), Fields!date1.Value)
this way the data is sorted by calendar date, not by text
-- Scott
I´m trying to define a column chart grouped by date and I can´t find the
proper way.
What I need is to show every month from one date to another even if there´s
no data in a specific month.
I also need to sum data from different recordsets grouping by month + year.
For example:
MY DATASETS
ds1:
date1 > Total1
1/1/2007 > 20
9/1/2007 > 15
1/3/2007 > 10
1/4/2007 > 40
1/5/2007 > 25
ds2:
date2 > Total2
1/2/2007 > 2
9/2/2007 > 1
1/4/2007 > 5
1/4/2007 > 4
1/6/2007 > 3
PARAMETERS:
StartDate: 1/1/2007
EndDate: 31/12/2007
MY CHART SHOULD SHOW:
January 2007 > 35
February 2007 > 3
March 2007 > 10
April 2007 > 49
May 2007 > 25
June 2007 > 3
July 2007 > 0
August 2007 > 0
September 2007 > 0
October 2007 > 0
November 2007 > 0
December 2007 > 0
How can I do this?
What must I put in the chart group?, is there any "UNION" option in groups?
(i.e. month(Fields!Date.Value, "ds1") & " " & year(Fields!Date.Value, "ds1")
UNION month(Fields!Date.Value, "ds2") & " " & year(Fields!Date.Value, "ds2")
How do I set the values?
Any help will be apreciated.
Thanks,
MónicaOn Nov 5, 12:48 pm, "M=F3nica" <monica.d...@.augure.com> wrote:
> Hi,
> I=B4m trying to define a column chart grouped by date and I can=B4t find =the
> proper way.
> What I need is to show every month from one date to another even if there==B4s
> no data in a specific month.
> I also need to sum data from different recordsets grouping by month + yea=r=2E
> For example:
> MY DATASETS
> ds1:
> date1 > Total1
> 1/1/2007 > 20
> 9/1/2007 > 15
> 1/3/2007 > 10
> 1/4/2007 > 40
> 1/5/2007 > 25
> ds2:
> date2 > Total2
> 1/2/2007 > 2
> 9/2/2007 > 1
> 1/4/2007 > 5
> 1/4/2007 > 4
> 1/6/2007 > 3
> PARAMETERS:
> StartDate: 1/1/2007
> EndDate: 31/12/2007
> MY CHART SHOULD SHOW:
> January 2007 > 35
> February 2007 > 3
> March 2007 > 10
> April 2007 > 49
> May 2007 > 25
> June 2007 > 3
> July 2007 > 0
> August 2007 > 0
> September 2007 > 0
> October 2007 > 0
> November 2007 > 0
> December 2007 > 0
> How can I do this?
> What must I put in the chart group?, is there any "UNION" option in group=s?
> (i.e. month(Fields!Date.Value, "ds1") & " " & year(Fields!Date.Value, "ds=1")
> UNION month(Fields!Date.Value, "ds2") & " " & year(Fields!Date.Value, "ds=2")
> How do I set the values?
> Any help will be apreciated.
> Thanks,
> M=F3nica
Unfortunately, you cannot Union two datasets together (wish you
could). The data has to be aggregated before it is delivered to the
report. I've had suggestions to me of (1) Custom DataSets, (2)
Analysis Server joined Cubes, (3) SELECT from a SQL Server containing
Linked Servers to the two datasets, then UNION on the server and
return a single dataset to SSRS.
Your second issue, Group By Month, create your Chart based off of
DataSet 1, add the DATE1 as a Category, then go to Chart Properties,
Data Tab, select the Category group, Edit, and change the Group
Expression to something like:
=3DDateAdd( d, 1-Day(Fields!date1.Value), Fields!date1.Value)
then change the Label to
=3DFormat( Fields!date1.Value, "MMMM yyyy" )
and change the Sorting to
=3DDateAdd( d, 1-Day(Fields!date1.Value), Fields!date1.Value)
this way the data is sorted by calendar date, not by text
-- Scott
chart and localization
I'm not able to define the chart y-axis maximum and minimun to be fixed
0,2 and -0,2. I have defined the report language as finnish and in
editor the everything works fine but after deploying and in preview mode
reporting services changes the limits to -15 and 15. I suppose the
problem is the the ',' decimal separator. I have set IE and asp.net
local to finnish and the OS (XP PRO EN) default locals to the use
finnish number formats. All other formattings in the report are just
fine, so the only problem is the chart. Does anyone know how to fix this
problem?I know this might be a stupid question but have you tried setting it to
0.2 instead of 0,2?
I had a few issues with number formatting in 2000 too, when trying to
use Norwegian formats. I ended up using US/UK numbers then applying
format codes for displaying.
There are also significant issues in 2005 data and preview tab with
European date formats (dd/mm/yyyy). It works fine when deployed.
The point I am aiming at is that the preview tab is not that good an
indicator of how the report may behave when deployed, primarily because
there are a number of issues when using non-US locales.
Regards
Chris
Pyry Grönholm wrote:
> I'm not able to define the chart y-axis maximum and minimun to be
> fixed 0,2 and -0,2. I have defined the report language as finnish and
> in editor the everything works fine but after deploying and in
> preview mode reporting services changes the limits to -15 and 15. I
> suppose the problem is the the ',' decimal separator. I have set IE
> and asp.net local to finnish and the OS (XP PRO EN) default locals to
> the use finnish number formats. All other formattings in the report
> are just fine, so the only problem is the chart. Does anyone know how
> to fix this problem?|||Yes I have.
The behavior is quite strange that way as well.
I'd like to have the scale between 0.2 and -0.2. If I set these values
the scale end up to be 0.2 and -1.0. So the negative side somehow fails.
If I set range from 0,2 to -0,2 I'll get a range from 2 to -2 so
probably the '.' is anyway the corrent decimal separator.
Does anyone have idea why I'm not able to set the negative decimal value
to minimun?
-Pyry GRönholm
Chris wrote:
> I know this might be a stupid question but have you tried setting it to
> 0.2 instead of 0,2?
> I had a few issues with number formatting in 2000 too, when trying to
> use Norwegian formats. I ended up using US/UK numbers then applying
> format codes for displaying.
> There are also significant issues in 2005 data and preview tab with
> European date formats (dd/mm/yyyy). It works fine when deployed.
> The point I am aiming at is that the preview tab is not that good an
> indicator of how the report may behave when deployed, primarily because
> there are a number of issues when using non-US locales.
> Regards
> Chris
>
> Pyry Grönholm wrote:
>
>>I'm not able to define the chart y-axis maximum and minimun to be
>>fixed 0,2 and -0,2. I have defined the report language as finnish and
>>in editor the everything works fine but after deploying and in
>>preview mode reporting services changes the limits to -15 and 15. I
>>suppose the problem is the the ',' decimal separator. I have set IE
>>and asp.net local to finnish and the OS (XP PRO EN) default locals to
>>the use finnish number formats. All other formattings in the report
>>are just fine, so the only problem is the chart. Does anyone know how
>>to fix this problem?
>
>
0,2 and -0,2. I have defined the report language as finnish and in
editor the everything works fine but after deploying and in preview mode
reporting services changes the limits to -15 and 15. I suppose the
problem is the the ',' decimal separator. I have set IE and asp.net
local to finnish and the OS (XP PRO EN) default locals to the use
finnish number formats. All other formattings in the report are just
fine, so the only problem is the chart. Does anyone know how to fix this
problem?I know this might be a stupid question but have you tried setting it to
0.2 instead of 0,2?
I had a few issues with number formatting in 2000 too, when trying to
use Norwegian formats. I ended up using US/UK numbers then applying
format codes for displaying.
There are also significant issues in 2005 data and preview tab with
European date formats (dd/mm/yyyy). It works fine when deployed.
The point I am aiming at is that the preview tab is not that good an
indicator of how the report may behave when deployed, primarily because
there are a number of issues when using non-US locales.
Regards
Chris
Pyry Grönholm wrote:
> I'm not able to define the chart y-axis maximum and minimun to be
> fixed 0,2 and -0,2. I have defined the report language as finnish and
> in editor the everything works fine but after deploying and in
> preview mode reporting services changes the limits to -15 and 15. I
> suppose the problem is the the ',' decimal separator. I have set IE
> and asp.net local to finnish and the OS (XP PRO EN) default locals to
> the use finnish number formats. All other formattings in the report
> are just fine, so the only problem is the chart. Does anyone know how
> to fix this problem?|||Yes I have.
The behavior is quite strange that way as well.
I'd like to have the scale between 0.2 and -0.2. If I set these values
the scale end up to be 0.2 and -1.0. So the negative side somehow fails.
If I set range from 0,2 to -0,2 I'll get a range from 2 to -2 so
probably the '.' is anyway the corrent decimal separator.
Does anyone have idea why I'm not able to set the negative decimal value
to minimun?
-Pyry GRönholm
Chris wrote:
> I know this might be a stupid question but have you tried setting it to
> 0.2 instead of 0,2?
> I had a few issues with number formatting in 2000 too, when trying to
> use Norwegian formats. I ended up using US/UK numbers then applying
> format codes for displaying.
> There are also significant issues in 2005 data and preview tab with
> European date formats (dd/mm/yyyy). It works fine when deployed.
> The point I am aiming at is that the preview tab is not that good an
> indicator of how the report may behave when deployed, primarily because
> there are a number of issues when using non-US locales.
> Regards
> Chris
>
> Pyry Grönholm wrote:
>
>>I'm not able to define the chart y-axis maximum and minimun to be
>>fixed 0,2 and -0,2. I have defined the report language as finnish and
>>in editor the everything works fine but after deploying and in
>>preview mode reporting services changes the limits to -15 and 15. I
>>suppose the problem is the the ',' decimal separator. I have set IE
>>and asp.net local to finnish and the OS (XP PRO EN) default locals to
>>the use finnish number formats. All other formattings in the report
>>are just fine, so the only problem is the chart. Does anyone know how
>>to fix this problem?
>
>
Sunday, February 12, 2012
Char and VarChar Datatype
Hi ,
What is the diff within Char and Varchar ? If define Char(10) in TableA
and this field is store the State code and the length is a non standard. User
can key in the length from 1 to 10.
Understand that I should define this field as VarChar(10) because is it a
no fixed length. But I don't really undertand what is the diff between this
two datatype in the backend structure ? It save the space ?
Travis Tan
In the backend char(10) is always stored as 10 characters (bytes), which
can give you problems when doing string comparisons because the string
will be padded with trailing spaces.
Varchar(10) will store a 32 bit integer (4 bytes) at the front of the
field to indicate the field length, followed by the actual number of
characters in the string.
So if you store a 2 character string in a varchar(10) it will use 6
bytes storage, if you store a 10 character string it will store 14
bytes.
HTH
Regards
Darren Gosbell [MCSD]
<dgosbell_at_yahoo_dot_com>
Blog: http://www.geekswithblogs.net/darrengosbell
What is the diff within Char and Varchar ? If define Char(10) in TableA
and this field is store the State code and the length is a non standard. User
can key in the length from 1 to 10.
Understand that I should define this field as VarChar(10) because is it a
no fixed length. But I don't really undertand what is the diff between this
two datatype in the backend structure ? It save the space ?
Travis Tan
In the backend char(10) is always stored as 10 characters (bytes), which
can give you problems when doing string comparisons because the string
will be padded with trailing spaces.
Varchar(10) will store a 32 bit integer (4 bytes) at the front of the
field to indicate the field length, followed by the actual number of
characters in the string.
So if you store a 2 character string in a varchar(10) it will use 6
bytes storage, if you store a 10 character string it will store 14
bytes.
HTH
Regards
Darren Gosbell [MCSD]
<dgosbell_at_yahoo_dot_com>
Blog: http://www.geekswithblogs.net/darrengosbell
Char and VarChar Datatype
Hi ,
What is the diff within Char and Varchar ? If define Char(10) in TableA
and this field is store the State code and the length is a non standard. Use
r
can key in the length from 1 to 10.
Understand that I should define this field as VarChar(10) because is it a
no fixed length. But I don't really undertand what is the diff between this
two datatype in the backend structure ? It save the space ?
Travis TanIn the backend char(10) is always stored as 10 characters (bytes), which
can give you problems when doing string comparisons because the string
will be padded with trailing spaces.
Varchar(10) will store a 32 bit integer (4 bytes) at the front of the
field to indicate the field length, followed by the actual number of
characters in the string.
So if you store a 2 character string in a varchar(10) it will use 6
bytes storage, if you store a 10 character string it will store 14
bytes.
HTH
Regards
Darren Gosbell [MCSD]
<dgosbell_at_yahoo_dot_com>
Blog: http://www.geekswithblogs.net/darrengosbell
What is the diff within Char and Varchar ? If define Char(10) in TableA
and this field is store the State code and the length is a non standard. Use
r
can key in the length from 1 to 10.
Understand that I should define this field as VarChar(10) because is it a
no fixed length. But I don't really undertand what is the diff between this
two datatype in the backend structure ? It save the space ?
Travis TanIn the backend char(10) is always stored as 10 characters (bytes), which
can give you problems when doing string comparisons because the string
will be padded with trailing spaces.
Varchar(10) will store a 32 bit integer (4 bytes) at the front of the
field to indicate the field length, followed by the actual number of
characters in the string.
So if you store a 2 character string in a varchar(10) it will use 6
bytes storage, if you store a 10 character string it will store 14
bytes.
HTH
Regards
Darren Gosbell [MCSD]
<dgosbell_at_yahoo_dot_com>
Blog: http://www.geekswithblogs.net/darrengosbell
Subscribe to:
Posts (Atom)