Skip to content
Advertisement

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 not to use the string

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 ) …

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

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

Advertisement