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 not to use the string
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 such meta-data? I
Creating an index on a table variable
Can you create an index on a table variable in SQL Server 2000? i.e. DECLARE @TEMPTABLE TABLE ( [ID] [int] NOT NULL PRIMARY KEY ,[Name] [nvarchar] (255) COLLATE DATABASE_DEFAULT NULL ) …
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 the varchar value ‘1,2,3,5,4,6,7,98,234’ to data
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) only
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 …
Using Environment variables in T-SQL
How can I read the value of a system environment variable in a T-SQL script? This is to run on SQL Server 2005.
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 Although there is clearly some
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. …