?
Solved

T-SQL to Update Table Dynamically

Posted on 2016-10-07
2
Medium Priority
?
86 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 51

Accepted Solution

by:
Vitor Montalvão earned 2000 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

I have a large data set and a SSIS package. How can I load this file in multi threading?
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
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.
Suggested Courses

765 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