Solved

T-SQL to Update Table Dynamically

Posted on 2016-10-07
2
56 Views
Last Modified: 2016-10-07
I had this question after viewing T-SQL to Update Table Dynamically.

How to fix single qutation in this query:

DECLARE @ChangingAsIsColumnsToTheEquivelantValuesSQL varchar (255);
SET @ChangingAsIsColumnsToTheEquivelantValuesSQL = 'SELECT
  ID 
, ServiceFees
,(Case Financed 
   WHEN N'False' THEN N'F' WHEN N'True' THEN N'T' END) As Financed
,(Case OutsideBranches 
  WHEN N'False' THEN N'F' WHEN N'True' THEN N'F' END) As OutsideBranches
FROM MyTable

EXECUTE(@ChangingAsIsColumnsToTheEquivelantValuesSQL)

Open in new window



Thanks a lot in advance.
Harreni
0
Comment
Question by:Harreni
2 Comments
 
LVL 48

Accepted Solution

by:
Vitor Montalvão earned 500 total points
ID: 41833697
Just add another the single quote for each one:
DECLARE @ChangingAsIsColumnsToTheEquivelantValuesSQL varchar (255);
SET @ChangingAsIsColumnsToTheEquivelantValuesSQL = 'SELECT
  ID 
, ServiceFees
,(Case Financed 
   WHEN N''False'' THEN N''F'' WHEN N''True'' THEN N''T'' END) As Financed
,(Case OutsideBranches 
  WHEN N''False'' THEN N''F'' WHEN N''True'' THEN N''F'' END) As OutsideBranches
FROM MyTable'

EXECUTE(@ChangingAsIsColumnsToTheEquivelantValuesSQL)

Open in new window

0
 

Author Closing Comment

by:Harreni
ID: 41833717
Thanks a lot Vitor.
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question