How to create portable inserts from SQL Server?

Now it generates type inserts

INSERT [Bla] ([id], [description], [name], [version])
VALUES (CAST(1 AS Numeric(19, 0)), convert(t...

This is a very specific SQL server. I would like to create a script that anyone can use, database agnostic. I have very simple data types - varchars, numbers, date, bits (boolean).

I think,

insert into bla values (1, 'die', '2001-01-01 11:11:11')

should work in all DBMS, right?

+3
source share
3 answers

Some basic rules:

Get rid of the square brackets. In your case, they are not needed - even in SQL Server. (At the same time, make sure that you never use reserved words or special characters in column or table names).

( ), (, "" ).

, , : my_table my_table, "my_table" "my_table" . , .

CAST ( ).

convert() SQL Server CAST.

, ( "1" ). , 1 ().

ANSI (, DATE '2011-03-14') DATE/TIMESTAMP, SQL Server . .

+3

Wikipedia SQL SQL , MS SQL, PostgreSQL, Oracle ..

, ANSI, .

, , .

+2

, dbmses, , . , DATE , DB ORACLE, , , , ORACLE , ORACLE.

, , ?

If you are serious about this, you really need to transfer data between the hydrogen DBMS and know a little about trying to use SqlFairy, available from CPAN. The sheer size of this download should be enough to convince you how complicated this problem is.

0
source

All Articles