That would only happen if PostCode
is missing a space.
You could add conditionality such that all of PostCode
is retrieved should a space not be found as follows
select SUBSTRING(PostCode, 1 ,
case when CHARINDEX(' ', PostCode ) = 0 then LEN(PostCode)
else CHARINDEX(' ', PostCode) -1 end)
Related Contents:
- Sql Server ‘Saving changes is not permitted’ error ► Prevent saving changes that require table re-creation
- How to restore to a different database in SQL Server?
- How to connect to local instance of SQL Server 2008 Express
- How to check date of last change in stored procedure or function in SQL server
- Enable ‘xp_cmdshell’ SQL Server
- A transport-level error has occurred when receiving results from the server [closed]
- optional parameters in SQL Server stored proc?
- Export query result to .csv file in SQL Server 2008
- How to convert float to varchar in SQL Server
- “The ‘Microsoft.ACE.OLEDB.12.0’ provider is not registered on the local machine” Error in importing process of xlsx to a sql server
- SQL Add foreign key to existing column
- How to edit one specific row in Microsoft SQL Server Management Studio 2008?
- Add column to SQL Server
- Why use the SQL Server 2008 geography data type?
- What does “select 1 from” do?
- How to declare an array inside MS SQL Server Stored Procedure?
- Adding an administrator user to SQL Server 2008
- “” is not a valid login or you do not have permission” on sql server installation
- SQL Server Files Local or NAS or SAN?
- Activity monitor is unable to execute queries against server
- How can I see who is connected to my db?
- How can I have SQL Server Management Studio 2008 connect to my instances automatically?
- Optional parameters in SQL Server stored procedure
- varchar(max) everywhere?
- How to add hours to current date in SQL Server?
- How to install SQL Server Management Studio 2008 component only [closed]
- Cannot resolve the collation conflict between “SQL_Latin1_General_CP1_CI_AS” and “Latin1_General_CI_AI” in the equal to operation
- How to re-seed a table identity in SQL Server 2008 and undo it all safely?
- SQL MERGE statement to update data
- Where are SQL Server connection attempts logged?
- How to check if datetime happens to be Saturday or Sunday in SQL Server 2008
- Text was truncated or one or more characters had no match in the target code page When importing from Excel file
- Win32Exception (0x80004005): The wait operation timed out
- Getting error while running 50 MB script on SQL Server 2008 R2
- Auto-increment primary key in SQL tables
- How would one use Lucene.NET to help implement search on a site like Stack Overflow?
- How many characters in varchar(max)?
- What is the default transaction isolation level for SQL Server with ADO.NET?
- Does the size used with NVARCHAR matter?
- how to rename column name with T-SQL
- ALTER TABLE on dependent column
- Invalid object name SQL Server 2008 R2 – Stored procedure
- What is the use of SYNONYM?
- storing passwords in SQL Server
- Reporting Services permissions on SQL Server R2 SSRS
- T-SQL substring – separating first and last name
- “Primary Filegroup is Full” in SQL Server 2008 Standard for no apparent reason
- how to create and call scalar function in sql server 2008
- T-SQL: Export to new Excel file
- How to deploy SQL Server Compact Edition 4.0?