Created a stored procedure that pulls a query. In the query, one of the fields, called companyCode, can have char, numbers, char&numbers or null data.
Example the field could contain: A1234 or 1234 or NULL
I don't have access to the field definition.
I created a Job to email out the stored procedure. When I run the query there are 1415 records returned. When I execute the stored procedure there are 1415 records returned. When I run the job there are only 1118 records returned.
I noticed when I don't do a sort by "companyCode" then I get 2 records.
When I do a sort by companyCode DESC I get 1118 records. The ones that don't show up are the NULL ones.
Working with SSMS - SQL 2008 R2
Here's the query
co_organization WITH (NOLOCK)
WHERE org_name != N'Enter Value'
ORDER BY org_companycode DESC
Here's the job
@profile_name = 'Database Mail',
@subject='Member Companies Extract',
@body='Attached is the Member Companies. ',
@query ='exec dbo.member_companies',
@query_attachment_filename = 'MemberCompanies.csv',
@execute_query_database = 'nf2014',
@attach_query_result_as_file = 1,
@query_result_header = 1,
@query_result_width = 32767,
@query_result_separator = '|' ,