Solved

T-SQL to Update Table Dynamically

Posted on 2016-10-07
2
74 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 50

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

724 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