I have a csv file and i need to import it to a table in sql 2005 or 2008. The column names and count in the csv are different from the table column names and count. The csv is splitted by a ‘;’ . Example CSV FILEcontents: SQL Person Table Answer I’d create a temporary table, bulk insert the …
Tag: sql
What is the difference between JOIN and UNION?
What is the difference between JOIN and UNION? Can I have an example?
How to use variables in SQL statement in Python?
I have the following Python code: where var1 is an integer, var2 and var3 are strings. How can I write the variable names without Python including them as part of the query text? Answer Note that the parameters are passed as a tuple. The database API does proper escaping and quoting of variables. Be careful n…
SQL Server: Extract Table Meta-Data (description, fields and their data types)
I am trying to find a way to extract information about my tables in SQL Server (2008). The data I need needs to include the description of the table (filled from the Description property in the Properties Window), a list of fields of that table and their respective data types. Is there any way I can extract s…
Passing a varchar full of comma delimited values to a SQL Server IN function
Duplicate of Dynamic SQL Comma Delimited Value Query Parameterized Queries with Like and In I have a SQL Server Stored Procedure where I would like to pass a varchar full of comma delimited values to an IN function. For example: This does not work of course. I get the error: Conversion failed when converting …
SQL Script to alter ALL Foreign Keys to add ON DELETE CASCADE
I have a SQL 2005 database with approx 250 tables. I want to temporarily enable ON DELETE CASCADE to all of the Foreign Keys so that I can do a bulk delete easily. I then want to turn off ON DELETE CASCADE on all Foreign Keys. The only way I know of doing this, is to use Management Studio to
conditional unique constraint
I have a situation where i need to enforce a unique constraint on a set of columns, but only for one value of a column. So for example I have a table like Table(ID, Name, RecordStatus). RecordStatus can only have a value 1 or 2 (active or deleted), and I want to create a unique constraint on (ID, RecordStatus…
Will a SQL Server Job skip a scheduled run if it is already running?
If you schedule a SQL Server job to run every X number of minutes, and it does not finish the previous call before the # of minutes is up, will it skip the run since it is already running, or will it …
How to avoid Sql Query Timeout
I have RO access on a SQL View. This query below times out. How to avoid this? The error message I get is: Msg 121, Level 20, State 0, Line 0 A transport-level error has occurred when receiving results from the server (provider: TCP Provider, error: 0 – The semaphore timeout period has expired.) Answer …
Foreign key constraint may cause cycles or multiple cascade paths?
I have a problem when I try to add constraints to my tables. I get the error: Introducing FOREIGN KEY constraint ‘FK74988DB24B3C886’ on table ‘Employee’ may cause cycles or multiple cascade paths. …