sql

How to determine SQL Server stored procedure parmeters at run time in .NET?

Is there any way for an application to determine the parameters and paramter types of a stored procedure at run time? ...

How do I get the value of the autogenerated fields using Postgresql?

I have a postgres table like this: CREATE SEQUENCE seq; CREATE TABLE tbl (id INTEGER DEFAULT VALUE nextval('seq'), data VARCHAR); When I insert into the table: INSERT INTO tbl (data) VALUES ('something'); How can I get back the value of the id field for the record I just created? (Note, I may have got some of the SQL syntax a bit ...

Multiple insert problem

I am doing a multiple insert in vba access query as below: Private Sub btnSubmit_Enter() DoCmd.RunSQL ("insert into tblAutonumber (Dummy)values ('DummyValue')") Dim lastAutonumber As Long lastAutonumber = DMax("Autonumber", "tblAutonumber") txtAutoNumber.Value = lastAutonumber DoCmd.RunSQL ("insert into tbltesting " & _ "(Empid, Te...

calling a stored proc over a dblink

I am trying to call a stored procedure over a database link. The code looks something like this: declare symbol_cursor package_name.record_cursor; symbol_record package_name.record_name; begin symbol_cursor := package_name.function_name('argument'); loop fetch symbol_cursor into symbol_record; exit w...

Unnest an SQL statement

I have this working SQL statement: select oriseqs.newID from oriseqs WHERE oriseqs.singlets=1 AND oriseqs.newID not in (select newID from cleanreport WHERE trash!="") My question is how to avoid doing one select inside another in this particular case. I mean to rewrite the select statement in a way that there is no nested select. He...

SQL Server 2008 - Case / If statements in SELECT Clause.

Hi, I have a Query that's supposed to run like this - If(var = xyz) SELECT col1, col2 ELSE IF(var = zyx) SELECT col2, col3 ELSE SELECT col7,col8 FROM . . . How do I achieve this in T-SQL without writing separate queries for each clause? Currently I'm running it as IF (var = xyz) { Query1 } ELSE IF (var = zyx) { ...

Concatenating Columns from a Result Set in SQL Server 2000

I have a query that returns data in the following form attribute value --------- ---------- petid 1000 name buttercup species cat age 10 owner Bob Dole Basically I want to go through every row and return the fields name and species in a single string, so here the result wou...

How to structure multiple users with multiple permission levels?

The site I am working with has a somewhat convoluted way with dealing with users and permissions. These are the user types: User Facility Approver Facility Admin Corporate Approver Corporate Admin Now there are also facilities, and that is where these permission levels come into play. Facilities are linked to users and user levels ...

Fill entire SQL table column

I just added a new column in my DB which I need to propagate with a specific text value (Confirmed). Is there a simple way to apply to all my data entries so I don't have to go through all my rows and type the value in? Thanks ...

sqlite SELECT AVG returns null

Does anyone know why a SQL SELECT query returns no rows when SELECTing from an empty table, but when trying to SELECT the AVG from a column in an empty table it returns < null >? The difference in behavior just seems odd to me. I’m using a sqlite database if that makes any difference. Here are the two queries: Normal select: SELECT ...

Developing MySQL Stored Procedures with Intellisense?

Hello, i've looking for an IDE for MySQL with intellisense, which would help a lot. Any suggestions? Thanks! ...

Negating an arbitrary where clause condition (including the null tests)

I want to efficiently check if a table contains any rows that match <condition A> and do not match <condition B>, where the conditions are arbitrary. In Oracle, this almost works: select count(*) from dual where exists ( select * from people where (<condition A>) and not (<condition B>) ); -- returns zero if all rows that match <...

LINQ to SQL - Left Outer Join with multiple join conditions

I have the following SQL which I am trying to translate to LINQ: SELECT f.value FROM period as p LEFT OUTER JOIN facts AS f ON p.id = f.periodid AND f.otherid = 17 WHERE p.companyid = 100 I have seen the typical implementation of the left outer join (ie. into x from y in x.DefaultIfEmpty() etc.) but am unsure how to introduce the oth...

How do you drop a default value in T-SQL?

I know the syntax: ALTER TABLE [TheTable] DROP CONSTRAINT [TheDefaultConstraint] but how to I drop the default constraint when I don't know its name? (That is, it was autogenerated at CREATE TABLE time.) ...

What would be the best way to write this query

I have a table in my database that has 1.1MM records. I have another table in my database that has about 2000 records under the field name, "NAME". What I want to do is do a search from Table 1 using the smaller table and pull the records where they match the smaller tables record. For example Table 1 has First Name, Last Name. Table 2 h...

Populate list box from a table in vba

I am developing a vba form for employee database, in that there is a search criteria for userid and employees name with the userid should be displayed in a list box control which comes from a single table I need to populate a list box with value from a table according to a value in a text box which act as a search box (eg: userid) Plea...

How can i call the below function to populate my access form list control

I need to populate the access form list box from a access table. Below is the code which I copy-pasted on button click event: Public Sub PopulateLBWithData(DBPath As String, _ TableName As String, FieldName As String, _ oListControl As Object,Optional Distinct As Boolean = False, _ Optional OrderBy As String) ''#PURPOSE: Populate a l...

can we use packages in ms sql server 2008

can we use packages in ms sql server 2008...i m new to sql server ... if yes how it can be created and used.... ...

Query regarding dsn string in vba

Below is the code to fill a list box in a VBA application : Private Sub Form_Open(Cancel As Integer) ''#Populate list box control. Dim cnn As ADODB.Connection Dim strSQL As String Dim rst As ADODB.Recordset Dim strList As String On Error GoTo ErrHandler ''#Use DSN to Northwind. ''#Modify connection and connection str...

SQL Count Years on FromDATE to ToDate fields

Hi again, Suppose i have > ID FromDate ToDate > -- -------- ------- > 1 01/01/2005 30/6/2007 > 2 01/01/2008 31/12/2009 I want to count the years that are included on this 2 rows. Here is 1,5 years for the first row + 2 years from second row = To...