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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 NULL values as

Author  Topic 

jaffa_cree
Starting Member

13 Posts

Posted - 2005-08-09 : 03:52:16
When i use QA and execute a simple SELECT statement with results to grid, null values appear as a string NULL.
If i was to use results to file, the output file would save the nulls as a blank,empty cell/string. This is what i want to achieve through results to grid, and the osql utility.

I need to make the output in the results grid display blank cells for null values, rather then a string null.
Is there some TSQL statements i can add to do this?
This is also affecting scheduled jobs i have using the OSQL utility as output files have a string null value as opposed to being blank.

I have tried the ISNULL statement, and replaced with empty string of ''. e.g. ISNULL(dbo.col1, '')
Problem with that is if the column data type isnt a string, issues arrises.
If the data type is an integer, the null string becomes a 0. This will affect compution/aggregations.
If the data type is a datetime, the null string becomes 1900-01-01 00:00:00.000


Thanks

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-09 : 04:44:03
>>If the data type is an integer, the null string becomes a 0. This will affect compution/aggregations.

You have give more information on what you are doing

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2005-08-09 : 07:14:06
SELECT ISNULL(CONVERT(varchar(50), dbo.col1), '')

will give you the output of col1 (e.g. if it is an INT or DATETIME) as a string value, or as a blank string if it is NULL

[varchar(50) is big enough for INT, DATETIME and GUID]

Kristen
Go to Top of Page

kapilarya
Yak Posting Veteran

86 Posts

Posted - 2005-08-11 : 05:42:13
GOTO Enterprise manager and select the table and on right click you will find the export option. in target option select the text file, give the name of the text file. select all the rest options as default. this will copy spaces for null in dates and also for numeric fields

Kapil Arya
Go to Top of Page

jaffa_cree
Starting Member

13 Posts

Posted - 2005-08-11 : 05:54:34
quote:
Originally posted by Kristen

SELECT ISNULL(CONVERT(varchar(50), dbo.col1), '')

will give you the output of col1 (e.g. if it is an INT or DATETIME) as a string value, or as a blank string if it is NULL

[varchar(50) is big enough for INT, DATETIME and GUID]

Kristen



Thanks.
That works great.
Go to Top of Page

jaffa_cree
Starting Member

13 Posts

Posted - 2005-08-11 : 05:55:32
quote:
Originally posted by kapilarya

GOTO Enterprise manager and select the table and on right click you will find the export option. in target option select the text file, give the name of the text file. select all the rest options as default. this will copy spaces for null in dates and also for numeric fields

Kapil Arya





I am actually running an SQL script that i use QA to save to file.
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-08-11 : 05:56:38
why do i get the feeling you're a stargate fan jaffa_cree?

Go with the flow & have fun! Else fight the flow
Go to Top of Page
   

- Advertisement -