Skip to content

Instantly share code, notes, and snippets.

@codepedia
Last active March 15, 2017 17:38
Show Gist options
  • Save codepedia/ce5873c85b3e142f20e8 to your computer and use it in GitHub Desktop.
Save codepedia/ce5873c85b3e142f20e8 to your computer and use it in GitHub Desktop.
# find the diff between two tables.
( SELECT * FROM table1
EXCEPT
SELECT * FROM table2)
UNION ALL
( SELECT * FROM table2
EXCEPT
SELECT * FROM table1)
=====
insert into sometable select 'somethingelse to replace name', field1 , field2 , field3
where name = 'something'
# caused by saving the file as utf-16 .txt and not tab del.txt
[Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Unclosed quotation mark after the character string '��p'. (SQL-42000)
# how to fix "Unclosed quotation mark after the character string”.
[Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Unclosed quotation mark after the character string ')'. (SQL-42000)
in an insert we have a column with a comma with in the record. Like this : make's house
to solve this open an editor and replace single qoutes with two single qoutes (like this make''s house)and not double qoutes and it should work. Or just remove that single qoute.
==============================================================================================================================
select * into somebackup_table_that_does_not_exist from existing_table_with_data
insert into somebackup_table_that_exist_already select * from existing_table_with_data
==============================================================================================================================
# if we need to create a new table and add two empty columns.
select *, null, null from sometable;
==============================================================================================================================
ERROR: Error converting data type varchar to numeric.
Error Code: 8114
insert into sometable values('587','059540165','blah','mike','LISA','0','0','0','587','<< the is here, it expects 0 but it was empty string>>','0')
==============================================================================================================================
had three lines in a file, ad only two were being read. After looking around, it turned out that this is because the file has the formt.
** funny enough, the last line was not even visible to MSSQL.
file somefile.txt ASCII text, with very long lines, with CRLF line terminators
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment