Wednesday, March 28, 2012
Numbers show as exponential
I am using the code below to sum values for the web. Instead of getting
11911712.0, I am getting 1.19117e+007. Is there a way to prevent numbers
from being show in exponential?
IsNull(Convert(varchar(30),(SUM(CASE WHEN Treg.Region = 'AP' Then T.Value
ELSE NULL END))), ' ') AS strValue
Thanks in advance,
Steven
I'm guessing that T.Value is a floating point datatype?
If so, then the problem is deeper then a display issue. Floating point datatypes only store so many signifigant digits of precision - the other digits are lost. They are turned into 0's.
|||One thing you might try is to convert the number to a decimal before
converting it to a varchar...
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Steven K" <skaper@.troop.com> wrote in message
news:OIk2gv2PEHA.3660@.TK2MSFTNGP11.phx.gbl...
> Hello,
> I am using the code below to sum values for the web. Instead of getting
> 11911712.0, I am getting 1.19117e+007. Is there a way to prevent numbers
> from being show in exponential?
>
> IsNull(Convert(varchar(30),(SUM(CASE WHEN Treg.Region = 'AP' Then T.Value
> ELSE NULL END))), ' ') AS strValue
> --
> Thanks in advance,
> Steven
>
sql
Numbers show as exponential
I am using the code below to sum values for the web. Instead of getting
11911712.0, I am getting 1.19117e+007. Is there a way to prevent numbers
from being show in exponential?
IsNull(Convert(varchar(30),(SUM(CASE WHEN Treg.Region = 'AP' Then T.Value
ELSE NULL END))), ' ') AS strValue
--
Thanks in advance,
StevenI'm guessing that T.Value is a floating point datatype?
If so, then the problem is deeper then a display issue. Floating point datatypes only store so many signifigant digits of precision - the other digits are lost. They are turned into 0's.|||One thing you might try is to convert the number to a decimal before
converting it to a varchar...
--
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Steven K" <skaper@.troop.com> wrote in message
news:OIk2gv2PEHA.3660@.TK2MSFTNGP11.phx.gbl...
> Hello,
> I am using the code below to sum values for the web. Instead of getting
> 11911712.0, I am getting 1.19117e+007. Is there a way to prevent numbers
> from being show in exponential?
>
> IsNull(Convert(varchar(30),(SUM(CASE WHEN Treg.Region = 'AP' Then T.Value
> ELSE NULL END))), ' ') AS strValue
> --
> Thanks in advance,
> Steven
>
Numbers show as exponential
I am using the code below to sum values for the web. Instead of getting
11911712.0, I am getting 1.19117e+007. Is there a way to prevent numbers
from being show in exponential?
IsNull(Convert(varchar(30),(SUM(CASE WHEN Treg.Region = 'AP' Then T.Value
ELSE NULL END))), ' ') AS strValue
Thanks in advance,
StevenI'm guessing that T.Value is a floating point datatype'
If so, then the problem is deeper then a display issue. Floating point data
types only store so many signifigant digits of precision - the other digits
are lost. They are turned into 0's.|||One thing you might try is to convert the number to a decimal before
converting it to a varchar...
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Steven K" <skaper@.troop.com> wrote in message
news:OIk2gv2PEHA.3660@.TK2MSFTNGP11.phx.gbl...
> Hello,
> I am using the code below to sum values for the web. Instead of getting
> 11911712.0, I am getting 1.19117e+007. Is there a way to prevent numbers
> from being show in exponential?
>
> IsNull(Convert(varchar(30),(SUM(CASE WHEN Treg.Region = 'AP' Then T.Value
> ELSE NULL END))), ' ') AS strValue
> --
> Thanks in advance,
> Steven
>
Monday, March 19, 2012
Number formatting
I want the output formatted with commas so 95,000 instead of 95000 - how
would I do that?"Joe" <Joe@.discussions.microsoft.com> wrote in message
news:F11D15E1-2FFB-4ADE-85C3-F5C97E278214@.microsoft.com...
> Here's a quickie - I have a stored procedure which returns a list of
numbers.
> I want the output formatted with commas so 95,000 instead of 95000 - how
> would I do that?
Do it at the client, not at the server.|||Joe,
here is an attempt at doing it, this is definitely an overkill and can
reduce the performance in case you have a lot of data coming back,
Select
LEFT(Convert(varchar(12),Convert(money,95000),1),LEN(Convert(varchar(12),Convert(money,95000),1)) - 3)
I would agree with Greg it will be simpler & more efficient on the
front-end. But I just had to try and do it in the backend :)
Enjoy,
Rakesh Ajwani
MCSD, MCSD.NET
"Greg D. Moore (Strider)" wrote:
> "Joe" <Joe@.discussions.microsoft.com> wrote in message
> news:F11D15E1-2FFB-4ADE-85C3-F5C97E278214@.microsoft.com...
> > Here's a quickie - I have a stored procedure which returns a list of
> numbers.
> > I want the output formatted with commas so 95,000 instead of 95000 - how
> > would I do that?
> Do it at the client, not at the server.
>
>
Number formatting
.
I want the output formatted with commas so 95,000 instead of 95000 - how
would I do that?"Joe" <Joe@.discussions.microsoft.com> wrote in message
news:F11D15E1-2FFB-4ADE-85C3-F5C97E278214@.microsoft.com...
> Here's a quickie - I have a stored procedure which returns a list of
numbers.
> I want the output formatted with commas so 95,000 instead of 95000 - how
> would I do that?
Do it at the client, not at the server.|||Joe,
here is an attempt at doing it, this is definitely an overkill and can
reduce the performance in case you have a lot of data coming back,
Select
LEFT(Convert(varchar(12),Convert(money,9
5000),1),LEN(Convert(varchar(12),Con
vert(money,95000),1)) - 3)
I would agree with Greg it will be simpler & more efficient on the
front-end. But I just had to try and do it in the backend
Enjoy,
Rakesh Ajwani
MCSD, MCSD.NET
"Greg D. Moore (Strider)" wrote:
> "Joe" <Joe@.discussions.microsoft.com> wrote in message
> news:F11D15E1-2FFB-4ADE-85C3-F5C97E278214@.microsoft.com...
> numbers.
> Do it at the client, not at the server.
>
>
Monday, March 12, 2012
Number format with negatives
MattTry the following format code on the textbox:
##.00;(##.00)
More details about format codes for numeric values can be found on MSDN:
* http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconcustomnumericformatstrings.asp
* http://msdn.microsoft.com/library/en-us/cpguide/html/cpconcustomnumericformatstringsoutputexample.asp
* http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconstandardnumericformatstrings.asp
BTW: the currency sign will always depend on the setting of the Language property (either of the report or individual textboxes). Set the language to a specific culture and you should get currency signs accordingly.
-- Robert
Number format with negatives
MattTry the following format code on the textbox:
##.00;(##.00)
More details about format codes for numeric values can be found on MSDN:
* http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconcustomnumericformatstrings.asp
* http://msdn.microsoft.com/library/en-us/cpguide/html/cpconcustomnumericformatstringsoutputexample.asp
* http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconstandardnumericformatstrings.asp
BTW: the currency sign will always depend on the setting of the Language property (either of the report or individual textboxes). Set the language to a specific culture and you should get currency signs accordingly.
-- Robert
Number Format
Hi all,
I have developed a report in which I need the thousand seperator to be a decimal point.
Instead of presenting the number as 12,923.23 i require that the representation be 12.923,23.
I have tried to customize the the format with the hash value but have had no joy. Any help would be much appreciated.
Ivan
Here's one way to do it. Also if this will be done on the fly, it probably will work best as a user-defined function. You could also nest all of the replace functions for a single select for production, but I did it this way to be more readable.
declare @.test money
Set @.test = '12923.23'
Select Replace(Convert(varchar(50),@.test,1),',','[,]')
Select Replace(Convert(varchar(50),@.test,1),'.','[.]')
Select Replace(Convert(varchar(50),@.test,1),'[,]','.')
Select Replace(Convert(varchar(50),@.test,1),'[.]',',')
print @.test
|||Thanks for the help, its much appreciated.
I ended up sorting out the issue by changing the language property to Italian on the table and entering 'N' in the format property in the desired column.
This then gives the numerical representation which I was looking for.It works because this is the way that the Italians and many other countries represent their numbers.
|||where will i write this code? i right click the textbox carrying the number.From the menu choose properties and then select format tab.Then in the expression area if i write this code , there is an error.Could you help me?|||You must not write these code in expression editor.
you can write a code as a function in vb.net in report code editor. you need to call that fuction in expression editor.
you can impliment custom code to get the desired results
Number Format
Hi all,
I have developed a report in which I need the thousand seperator to be a decimal point.
Instead of presenting the number as 12,923.23 i require that the representation be 12.923,23.
I have tried to customize the the format with the hash value but have had no joy. Any help would be much appreciated.
Ivan
Here's one way to do it. Also if this will be done on the fly, it probably will work best as a user-defined function. You could also nest all of the replace functions for a single select for production, but I did it this way to be more readable.
declare @.test money
Set @.test = '12923.23'
Select Replace(Convert(varchar(50),@.test,1),',','[,]')
Select Replace(Convert(varchar(50),@.test,1),'.','[.]')
Select Replace(Convert(varchar(50),@.test,1),'[,]','.')
Select Replace(Convert(varchar(50),@.test,1),'[.]',',')
print @.test
|||Thanks for the help, its much appreciated.
I ended up sorting out the issue by changing the language property to Italian on the table and entering 'N' in the format property in the desired column.
This then gives the numerical representation which I was looking for.It works because this is the way that the Italians and many other countries represent their numbers.
|||where will i write this code? i right click the textbox carrying the number.From the menu choose properties and then select format tab.Then in the expression area if i write this code , there is an error.Could you help me?|||
You must not write these code in expression editor.
you can write a code as a function in vb.net in report code editor. you need to call that fuction in expression editor.
you can impliment custom code to get the desired results
Friday, March 9, 2012
nulled out - defaults instead?
I am converting a dbase based enterprise wide system that has almost 100
tables to convert into a vb .net system using ms sql server 2000 (I am
posting this both to ado .net newsgroups and sql server newsgroups). I am
working with a prototype where many of the columns in many of the tables
allow nulls. But often I can't call ... is null (in tsql) or isdbnull(...)
in vb .net on the same line as, say, 'or len(trim((dddd)) < 1' because this
throws an error if the col is null, since you can't measure anything when a
col is null.
Now null might have a place in the universe - like black holes - but not
being Stephen Hawkings I just don't know what that place is. But in vb .net
especially and to some extent in tsql also, it's just a pain in the ...
My question - is there any reason I shouldn't convert into tables where,
when the data is converted if it's empty or 0 (int) or # / / # (date), I
use defaults instead (eg, "", 0, 01/01/1900 respectively)? Do I lose
anything by doing this?
Tx for any help.
Bernie YaegerBernie,
Although I belong to the 'avoid nulls at all costs' camp,
you do lose something with defaults.
For example, 1/1/1900 is a valid date in many systems, so
using that date as the default will cause logical
problem. Likewise, a zero may (or may not) cause
problems when used instead of a NULL.
Think of the difference with summing a zero into an
aggregate vs taking an average. In the sum, you can
ignore the zero defaults since they are harmless, but
with the average you have to decide whether to include
them or not.
The key is how your application is coded. If you code
for defaults from the start, there are few difficulties
in making it all work smoothly since you will choose your
defaults and define how they are to be interpreted.
However, from the examples above, any code that includes
the default code in the domain of legal values can cause
you grief.
Russell Fields
>--Original Message--
>OK, I'm nulled out.
>I am converting a dbase based enterprise wide system
that has almost 100
>tables to convert into a vb .net system using ms sql
server 2000 (I am
>posting this both to ado .net newsgroups and sql server
newsgroups). I am
>working with a prototype where many of the columns in
many of the tables
>allow nulls. But often I can't call ... is null (in
tsql) or isdbnull(...)
>in vb .net on the same line as, say, 'or len(trim
((dddd)) < 1' because this
>throws an error if the col is null, since you can't
measure anything when a
>col is null.
>Now null might have a place in the universe - like black
holes - but not
>being Stephen Hawkings I just don't know what that place
is. But in vb .net
>especially and to some extent in tsql also, it's just a
pain in the ...
>My question - is there any reason I shouldn't convert
into tables where,
>when the data is converted if it's empty or 0 (int) or
# / / # (date), I
>use defaults instead (eg, "", 0, 01/01/1900
respectively)? Do I lose
>anything by doing this?
>Tx for any help.
>Bernie Yaeger
>
>.
>|||Allowing NULLS is a design decision that only you can make. IMHO, tri-state
logic is a pain because you often have to exclude data that make no logical
sense. I strongly prefer NOT NULL and default values in columns since it
simplifies the logical conditions. Just make sure your default values are
meaningful in your system and your application knows what to do with them.
NOT NULL and defaults help later when you maintain your application since
you can add columns without having to change existing code. Whatever choice
you make, apply it consistantly and document the few times when you
absolutely must deviate from the standard.
--
Geoff N. Hiten
SQL Server MVP
Senior Database Administrator
Careerbuilder.com
"Bernie Yaeger" <berniey@.cherwellinc.com> wrote in message
news:JIPZa.40432$_R5.12322590@.news4.srv.hcvlny.cv.net...
> OK, I'm nulled out.
> I am converting a dbase based enterprise wide system that has almost 100
> tables to convert into a vb .net system using ms sql server 2000 (I am
> posting this both to ado .net newsgroups and sql server newsgroups). I am
> working with a prototype where many of the columns in many of the tables
> allow nulls. But often I can't call ... is null (in tsql) or
isdbnull(...)
> in vb .net on the same line as, say, 'or len(trim((dddd)) < 1' because
this
> throws an error if the col is null, since you can't measure anything when
a
> col is null.
> Now null might have a place in the universe - like black holes - but not
> being Stephen Hawkings I just don't know what that place is. But in vb
.net
> especially and to some extent in tsql also, it's just a pain in the ...
> My question - is there any reason I shouldn't convert into tables where,
> when the data is converted if it's empty or 0 (int) or # / / # (date),
I
> use defaults instead (eg, "", 0, 01/01/1900 respectively)? Do I lose
> anything by doing this?
> Tx for any help.
> Bernie Yaeger
>|||Hi Russell,
Tx for your advice; I have considered some of the issues you raise and know
the consequences and how to deal with them, I believe.
Bernie
"Russell Fields" <rlfields@.sprynet.com> wrote in message
news:008101c36030$3efd7300$a501280a@.phx.gbl...
> Bernie,
> Although I belong to the 'avoid nulls at all costs' camp,
> you do lose something with defaults.
> For example, 1/1/1900 is a valid date in many systems, so
> using that date as the default will cause logical
> problem. Likewise, a zero may (or may not) cause
> problems when used instead of a NULL.
> Think of the difference with summing a zero into an
> aggregate vs taking an average. In the sum, you can
> ignore the zero defaults since they are harmless, but
> with the average you have to decide whether to include
> them or not.
> The key is how your application is coded. If you code
> for defaults from the start, there are few difficulties
> in making it all work smoothly since you will choose your
> defaults and define how they are to be interpreted.
> However, from the examples above, any code that includes
> the default code in the domain of legal values can cause
> you grief.
>
> Russell Fields
>
> >--Original Message--
> >OK, I'm nulled out.
> >
> >I am converting a dbase based enterprise wide system
> that has almost 100
> >tables to convert into a vb .net system using ms sql
> server 2000 (I am
> >posting this both to ado .net newsgroups and sql server
> newsgroups). I am
> >working with a prototype where many of the columns in
> many of the tables
> >allow nulls. But often I can't call ... is null (in
> tsql) or isdbnull(...)
> >in vb .net on the same line as, say, 'or len(trim
> ((dddd)) < 1' because this
> >throws an error if the col is null, since you can't
> measure anything when a
> >col is null.
> >
> >Now null might have a place in the universe - like black
> holes - but not
> >being Stephen Hawkings I just don't know what that place
> is. But in vb .net
> >especially and to some extent in tsql also, it's just a
> pain in the ...
> >
> >My question - is there any reason I shouldn't convert
> into tables where,
> >when the data is converted if it's empty or 0 (int) or
> # / / # (date), I
> >use defaults instead (eg, "", 0, 01/01/1900
> respectively)? Do I lose
> >anything by doing this?
> >
> >Tx for any help.
> >
> >Bernie Yaeger
> >
> >
> >.
> >|||With due respect to my colleagues, I fall into the 'Use Nulls when
necessary' camp... if you do not know the value, you do not know... Tri
state logic is a little more difficult, but I prefer the data to represent
reality...
And this is something where 'reasonable people differ' in their opinions...
"Bernie Yaeger" <berniey@.cherwellinc.com> wrote in message
news:JIPZa.40432$_R5.12322590@.news4.srv.hcvlny.cv.net...
> OK, I'm nulled out.
> I am converting a dbase based enterprise wide system that has almost 100
> tables to convert into a vb .net system using ms sql server 2000 (I am
> posting this both to ado .net newsgroups and sql server newsgroups). I am
> working with a prototype where many of the columns in many of the tables
> allow nulls. But often I can't call ... is null (in tsql) or
isdbnull(...)
> in vb .net on the same line as, say, 'or len(trim((dddd)) < 1' because
this
> throws an error if the col is null, since you can't measure anything when
a
> col is null.
> Now null might have a place in the universe - like black holes - but not
> being Stephen Hawkings I just don't know what that place is. But in vb
.net
> especially and to some extent in tsql also, it's just a pain in the ...
> My question - is there any reason I shouldn't convert into tables where,
> when the data is converted if it's empty or 0 (int) or # / / # (date),
I
> use defaults instead (eg, "", 0, 01/01/1900 respectively)? Do I lose
> anything by doing this?
> Tx for any help.
> Bernie Yaeger
>|||Just to clarify, I am not religiously opposed to using Nulls. I just think
the places where they apply are very few. If you have properly represented
Entity Relationships in your database, either you know about an entity or
that entity doesn't exist. Thus, you have a complete row in an appropriate
table or no row in that table.
Since most of us work in the real world where we have to live with inherited
databases, Nulls are a fact of life. I prefer to choose where I use nulls
and treat them as the exception rather than the rule. Again, this is just a
personal design preference and should not be taken as holy writ.
--
Geoff N. Hiten
SQL Server MVP
Senior Database Administrator
Careerbuilder.com
"Wayne Snyder" <wsnyder@.computeredservices.com> wrote in message
news:#63VdaLYDHA.384@.TK2MSFTNGP12.phx.gbl...
> With due respect to my colleagues, I fall into the 'Use Nulls when
> necessary' camp... if you do not know the value, you do not know... Tri
> state logic is a little more difficult, but I prefer the data to represent
> reality...
> And this is something where 'reasonable people differ' in their
opinions...
> "Bernie Yaeger" <berniey@.cherwellinc.com> wrote in message
> news:JIPZa.40432$_R5.12322590@.news4.srv.hcvlny.cv.net...
> > OK, I'm nulled out.
> >
> > I am converting a dbase based enterprise wide system that has almost 100
> > tables to convert into a vb .net system using ms sql server 2000 (I am
> > posting this both to ado .net newsgroups and sql server newsgroups). I
am
> > working with a prototype where many of the columns in many of the tables
> > allow nulls. But often I can't call ... is null (in tsql) or
> isdbnull(...)
> > in vb .net on the same line as, say, 'or len(trim((dddd)) < 1' because
> this
> > throws an error if the col is null, since you can't measure anything
when
> a
> > col is null.
> >
> > Now null might have a place in the universe - like black holes - but not
> > being Stephen Hawkings I just don't know what that place is. But in vb
> .net
> > especially and to some extent in tsql also, it's just a pain in the ...
> >
> > My question - is there any reason I shouldn't convert into tables where,
> > when the data is converted if it's empty or 0 (int) or # / / #
(date),
> I
> > use defaults instead (eg, "", 0, 01/01/1900 respectively)? Do I lose
> > anything by doing this?
> >
> > Tx for any help.
> >
> > Bernie Yaeger
> >
> >
>
Saturday, February 25, 2012
Null values
Hi,
How can I use "Derived Column" to check if a Datetime value is null or not and if null to insert 00/00/00 instead. ?
The background being that while using a "Derived Column" to change a Column from a (DT_DATE) to a (DT_DBTIMESTAMP) everytime I get a null value it see's it as a error.
And the column in particular has ~ 37 K blank / null fields so Im getting a lot of errors
So far I have tried to use something like
ISNULL([Column 34])
Or
SELECT ISNULL(ID, '00/00/0000') FROM [Column 34]
Or
SELECT ISNULL(au_id, '00/00/0000 00:00') AS ssn
FROM [Column 34
but none seems to work [Column 34] being the offending column.
What a normally use is just a simple "(DT_DBTIMESTAMP)[Column 34]"
in the expression column, which seems to work well, but here I get alot of errors
Any ideas?
Try
ISNULL([Column 34]) ? NULL(DT_DBTIMESTAMP) : (DT_DBTIMESTAMP)[Column 34]
Or something like that.
... ? ... : ... is the if then else operator! C++ stylee!!!
-Jamie
|||
You would use an expression like:
ISNULL([Column 34]) ? (DT_DBTIMESTAMP)"00/00/00" : (DT_DBTIMESTAMP)[Column 34]
Except, that will fail due to a conversion error, since 00/00/00 is not a valid DT_DBTIMESTAMP. You will need to use a valid date instead, I think.
Monday, February 20, 2012
NULL output when trying to script objects with SQL-DMO
procedure. Instead, it returns NULL. Please tell me what I'm doign wrong:
DECLARE @.oServer int
DECLARE @.method varchar(300)
DECLARE @.TSQL varchar(4000)
DECLARE @.ScriptType int
EXEC sp_OACreate 'SQLDMO.SQLServer', @.oServer OUT
EXEC sp_OASetProperty @.oServer, 'loginsecure', 'true'
EXEC sp_OAMethod @.oServer, 'Connect', NULL, 'US1SQLDEV'
SET @.ScriptType = 1|4|32|64|256|262144
SET @.method = 'Databases("Compass").' +
'StoredProcedures("p_rpt_Distance").Script' +
'(' + CAST (@.ScriptType AS VARCHAR) + ')'
EXEC sp_OAMethod @.oServer, @.method ,
@.TSQL OUTPUT
SELECT @.TSQL
EXEC sp_OADestroy @.oServercongratulations, you've found the slowest possible way to do this ;)
if your sql is going to be <=4000 chars, you should just go against
syscomments. otherwise, your variable won't be big enough, anyway.
if you're dead-set on using the object junk, check the script type.
you've got the script type of 64 (To File only) set, but no file name to
output to.
CadeBryant wrote:
> The following statement SHOULD generate a script of the specified stored
> procedure. Instead, it returns NULL. Please tell me what I'm doign wrong
:
> DECLARE @.oServer int
> DECLARE @.method varchar(300)
> DECLARE @.TSQL varchar(4000)
> DECLARE @.ScriptType int
> EXEC sp_OACreate 'SQLDMO.SQLServer', @.oServer OUT
> EXEC sp_OASetProperty @.oServer, 'loginsecure', 'true'
> EXEC sp_OAMethod @.oServer, 'Connect', NULL, 'US1SQLDEV'
> SET @.ScriptType = 1|4|32|64|256|262144
> SET @.method = 'Databases("Compass").' +
> 'StoredProcedures("p_rpt_Distance").Script' +
> '(' + CAST (@.ScriptType AS VARCHAR) + ')'
> EXEC sp_OAMethod @.oServer, @.method ,
> @.TSQL OUTPUT
> SELECT @.TSQL
> EXEC sp_OADestroy @.oServer
NULL issue
Instead of a record number being assigned to the first column of each row,
the database displays <NULL> in the column. How can I get the record number
to display in the database?
When I run my second PHP script, it retreives the data from the database. It
needs to display the data with the database record number, but instead
displays <NULL>.
$tday = date('Ymd');
$name2 = $HTTP_POST_VARS["name"];
$empNum = $HTTP_POST_VARS["empNum"];
$email = $HTTP_POST_VARS["email"];
$deptSta2 = $HTTP_POST_VARS["deptSta"];
$subject2 = $HTTP_POST_VARS["subject"];
$comments2 = $HTTP_POST_VARS["comments"];
$mailList = $HTTP_POST_VARS["mailList"];
$result=odbc_exec($connection,"INSERT INTO contact VALUES(NULL, '$tday',
'$name2', '$empNum', '$email', '$deptSta2', '$subject2', '$comments2',
'$mailList', 'N')");what is the first column? and wht does the insert or update stmnt look like?
"Npeart1" wrote:
> I have a PHP web form that takes data and posts it to the SQL database.
> Instead of a record number being assigned to the first column of each row,
> the database displays <NULL> in the column. How can I get the record numbe
r
> to display in the database?
> When I run my second PHP script, it retreives the data from the database.
It
> needs to display the data with the database record number, but instead
> displays <NULL>.
> $tday = date('Ymd');
> $name2 = $HTTP_POST_VARS["name"];
> $empNum = $HTTP_POST_VARS["empNum"];
> $email = $HTTP_POST_VARS["email"];
> $deptSta2 = $HTTP_POST_VARS["deptSta"];
> $subject2 = $HTTP_POST_VARS["subject"];
> $comments2 = $HTTP_POST_VARS["comments"];
> $mailList = $HTTP_POST_VARS["mailList"];
>
> $result=odbc_exec($connection,"INSERT INTO contact VALUES(NULL, '$tday',
> '$name2', '$empNum', '$email', '$deptSta2', '$subject2', '$comments2',
> '$mailList', 'N')");
>
Null Field Values not returned - For XML AUTO
instead of completely omitting them from the output?
I'm using FOR XML AUTO
Michael L wrote:
> Is there a way to get SQL to return NULL field values as 'empty' XML tags,
> instead of completely omitting them from the output?
> I'm using FOR XML AUTO
Use
FOM XML AUTO, ELEMENTS XSINIL
that way for a null value in a column you get
<Columnname xsi:nil="true"/>
where xsi is bound to http://www.w3.org/2001/XMLSchema-instance.
See "Using the XSINIL directive" in
<http://msdn2.microsoft.com/en-us/library/ms177400.aspx>
Martin Honnen -- MVP XML
http://JavaScript.FAQTs.com/
|||THANKS! I assume this only works in SQL Server 2005?
"Martin Honnen" <mahotrash@.yahoo.de> wrote in message
news:%23PvVNP2pHHA.4772@.TK2MSFTNGP05.phx.gbl...
> Michael L wrote:
> Use
> FOM XML AUTO, ELEMENTS XSINIL
> that way for a null value in a column you get
> <Columnname xsi:nil="true"/>
> where xsi is bound to http://www.w3.org/2001/XMLSchema-instance.
> See "Using the XSINIL directive" in
> <http://msdn2.microsoft.com/en-us/library/ms177400.aspx>
> --
> Martin Honnen -- MVP XML
> http://JavaScript.FAQTs.com/
|||Correct. This is only available in 2005. In 2000 you could always use
ISNULL(col, '') in the select clause (with cast adjustments for nonstring
types).
Best regards
Michael
"Michael L" <mlarter@.comcast.net> wrote in message
news:CMGdnckxp900QfjbnZ2dnUVZ_hCdnZ2d@.comcast.com. ..
> THANKS! I assume this only works in SQL Server 2005?
>
> "Martin Honnen" <mahotrash@.yahoo.de> wrote in message
> news:%23PvVNP2pHHA.4772@.TK2MSFTNGP05.phx.gbl...
>
Null Field Values not returned - For XML AUTO
instead of completely omitting them from the output?
I'm using FOR XML AUTOMichael L wrote:
> Is there a way to get SQL to return NULL field values as 'empty' XML tags,
> instead of completely omitting them from the output?
> I'm using FOR XML AUTO
Use
FOM XML AUTO, ELEMENTS XSINIL
that way for a null value in a column you get
<Columnname xsi:nil="true"/>
where xsi is bound to http://www.w3.org/2001/XMLSchema-instance.
See "Using the XSINIL directive" in
<http://msdn2.microsoft.com/en-us/library/ms177400.aspx>
Martin Honnen -- MVP XML
http://JavaScript.FAQTs.com/|||THANKS! I assume this only works in SQL Server 2005?
"Martin Honnen" <mahotrash@.yahoo.de> wrote in message
news:%23PvVNP2pHHA.4772@.TK2MSFTNGP05.phx.gbl...
> Michael L wrote:
> Use
> FOM XML AUTO, ELEMENTS XSINIL
> that way for a null value in a column you get
> <Columnname xsi:nil="true"/>
> where xsi is bound to http://www.w3.org/2001/XMLSchema-instance.
> See "Using the XSINIL directive" in
> <http://msdn2.microsoft.com/en-us/library/ms177400.aspx>
> --
> Martin Honnen -- MVP XML
> http://JavaScript.FAQTs.com/|||Correct. This is only available in 2005. In 2000 you could always use
ISNULL(col, '') in the select clause (with cast adjustments for nonstring
types).
Best regards
Michael
"Michael L" <mlarter@.comcast.net> wrote in message
news:CMGdnckxp900QfjbnZ2dnUVZ_hCdnZ2d@.co
mcast.com...
> THANKS! I assume this only works in SQL Server 2005?
>
> "Martin Honnen" <mahotrash@.yahoo.de> wrote in message
> news:%23PvVNP2pHHA.4772@.TK2MSFTNGP05.phx.gbl...
>