Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
romeck
Starting Member
16 Posts |
Posted - 2012-10-15 : 17:44:42
|
Hi there i have strange thing , my clients emploee sometimes puts double ' instead of " into contractors name .if i use insert TSQL ie:INSERT INTO [AA].[AA].[RA] ([concode]) VALUES ('''TK-BUD' ) then in the end in DB in concod field, there is only 'TK-BUD instead of ''TK-BUD . Now i cant compare it to data which is inserted via some soft (which can somehow insert '' correctly ) . So the question is what i have to do to insert '' correctly into DB.using :declare @xxx as varchar(50)set @xxx='''TK-BUD'INSERT INTO [AA].[AA].[RA] ([concode]) VALUES (@xxx) also do not help .THQ |
|
chadmat
The Chadinator
1974 Posts |
Posted - 2012-10-15 : 17:51:26
|
INSERT INTO [AA].[AA].[RA] ([concode]) VALUES ('''''TK-BUD' )-Chad |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2012-10-15 : 18:05:02
|
Another alternative that I recomend is to use the CHAR function:INSERT INTO [AA].[AA].[RA] ([concode]) VALUES (CHAR(39) + CHAR(39) + 'TK-BUD' ) EDIT: Doubled up the single quote. |
|
|
romeck
Starting Member
16 Posts |
Posted - 2012-10-15 : 20:00:52
|
@chadmat - no that wont work, couses error@Lamprey - :) yes thats work thanks (although i was expecting that simplier way exist couse i have to create function that have to analyse char after char in the 40 char long string which i presume is a bit not efficient , many many "if"s couse of ' could be first could be last or could be multiplied :) ) |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-10-15 : 22:08:28
|
quote: Originally posted by romeck @chadmat - no that wont work, couses error@Lamprey - :) yes thats work thanks (although i was expecting that simplier way exist couse i have to create function that have to analyse char after char in the 40 char long string which i presume is a bit not efficient , many many "if"s couse of ' could be first could be last or could be multiplied :) )
it will work seedeclare @test table(val varchar(30))insert @test values('''''test'),(char(39) + char(39) + 'test')select * from @testoutput----------------------------val------------------------------''test''test ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|