Microsoft SQL Server and SQL Server Management Studio
A category to select articles regarding Microsoft SQL Server and SQL Server Management Studio 2012.
Importing text files into tables in SQL Server database schemas can be done using different methods.
One method using SQL Server specific SQL is shown below.
SQL Script
If you want to use tab delimited source files you can type in the delimiter into FIELDDELIMITER using the tabulator key in SQL Server Management Studio.
BULK INSERT CSVTest FROM 'c:\csvtest.txt' WITH ( FIELDTERMINATOR = ',', ROWTERMINATOR = '\n' ) GO
- Hits: 9980
If you are confronted with the inconvenience of having to truncate all tables in a database in MS SQL Server, the following T-SQL might help.
Source Code
It is important to use the type varChar for the name @tab_name since its content is concatenated with some SQL command to truncate tables.
- Hits: 9777
In order to divide two integer type fields in SQL Server you will have to apply a type cast before applying the mathematical operation.
Else you will receive zero (0) as a result whenever one of the numbers is not null, which is obviously not what we want.
- Hits: 9910
Page 1 of 2