sql

Need a SQL statement focus on combination of tables but entries always with unique ID

Hi All, I need SQL code to solve the tables combination problem, described on below: Table old data: table old name version status lastupdate ID A 0.1 on 6/8/2010 1 B 0.1 on 6/8/2010 2 C 0.1 on 6/8/2010 3 D 0.1...

SQL Server connection help...

Using SQL Server 2005 I have the server connection name as (server1) in windows authentication mode, I want to change windows authentication mode to sql server authentication mode... when i try to change sql server authentication mode with username = sa & password = sa, it showing error... How to change the authentication mode or how ...

My NSMulipuleArray donesn't have objects

Hi, I am simply trying get the objects in my DB using an Array ie display the search results in another viewcontroller. I think the problem it that I am not linking the delegate to the controller and as a result my Array is not reading the objects when I put my sql statement in.... Here's what it looks like? + (void) getInitialDataToDi...

SQL alert for a stored procedure?

I have a SQL 2005 setup and am rather new :) Been cracking at this for a few hours and I just need some help. I have been able to setup alerts successfully for the standard "SQL server performance events", its fun. So I already have email alerts working. However I need the alert thing to run a stored procedure I have created, and depe...

Changing Database Name In Stored Procedures

Hi, I need to change the database name in SQL SERVER 2008 and use it in another project. However it consist hundreds of stored procedures and the name of the database should be changed in the stored procedures as well. Is there any way to do this? ...

Replace BIT values with some text

I have a BIT column with gender (0,1) and want to replace 0 and 1 in the resulting view with the words "man" and "woman". Can i do this right in the view with some system finction or i have to write my own function to do that? ...

SQL Server IS_NULLABLE

Good Morning, Just a quick question what this field actually means? I am trying to create an export script which follows this standard: lname varchar(30) **NOT NULL**, So if last name is_nullable=yes then would I put NULL rather than NOT NULL at the *'d code. Many Thanks, Joel ...

Good test database on Windows to play around with data retrieval operations in SQL?

I need a test database to practice joins and other kinds of data retrieval operations in SQL. What's a good free test database and RDBMS system to use on Windows? ...

Sql query listing Fathers and childs with joins, how to distinct them?

Having those tables: table_n1: | t1_id | t1_name | | 1 | foo | table_n2: | t2_id | t1_id | t2_name | | 1 | 1 | bar | I need a query that gives me two result: | names | | foo | | foo / bar | But i cant figure out the right way. I wrote this one: SELECT CONCAT_WS(' / ', table_n1.t1_name, table_...

Guid Primary /Foreign Key dilemma SQL Server

Hi guys, I am faced with the dilemma of changing my primary keys from int identities to Guid. I'll put my problem straight up. It's a typical Retail management app, with POS and back office functionality. Has about 100 tables. The database synchronizes with other databases and receives/ sends new data. Most tables don't have frequent ...

Finding a Identity Specification using SQL

Good Morning, I have a SQL Server database, of which there is a column that has an identity specification. However, if I do a SQL query such as: SELECT * FROM INFORMATION_SCHEMA.Columns where TABLE_NAME = It doesn't tell me if the column is an identity specification - is there a query that will? Many Thanks, Joel ...

SQL query root parent child records

Hi, We have nested folders with parent-child relationship. We use MySQL MyISAM DB. The data is stored in the DB in the following manner. Every time a child folder is created in the nested structure, the previous parentID is added. I want to get the RootFolderID of a folder which is added in the hierarchy as tabulated below. FoldID Par...

Need help building SQL Query (simple JOIN)

Hello! In my database, I have a "users", a "quests" and a "questings" table. A user can solve a quest. Solving a quest will save the "user_id" and the "quest_id" in my "questings" table. Now, I want to select all quests, a user has NOT solved (meaning there is no entry for this user and quest in "questings" table)! Let's say the user ...

How to use a value from one stored procedure in another?

I have the following statement in a Stored Procedure: DECLARE @Count INT EXEC @Count = GetItemCount 123 SELECT @Count Which calls another stored procedure with the following statement inside: SELECT COUNT(Item) FROM tblItem WHERE ID = @ID However when I test the call the EXEC outputs the value correctly but it is not assigned to th...

django left join with null

The model: class Product(models.Model): name = models.CharField(max_length = 128) def __unicode__(self): return self.name class Receipt(models.Model): name = models.CharField(max_length=128) components = models.ManyToManyField(Product, through='ReceiptComponent') class Admin: pass def __unicode__(self): return ...

SQL syntax error

Im using Microsoft SQL Server which I think is T-SQL or ANSI SQL. I want to search a database with a string. The matches that fit the begging of the string should come first then sort alphabetically. I.e. If the table contains FOO, BAR and RAP a search for the string 'R' should yield: RAP BAR In that order. Here is my attempt: S...

Can I create a table with check constrain whose values are dependent on sql query

Is it possible to create a table which has a check constraint on one of the column whose value lies within the result set given by another sql query eg. create table tablename ( name varchar(10), rollno int )check rollno in (select rollno from anotherDatabase.TableName,candidateRoll) or any thing like that. I dont have to use it an...

Hibernate - Restriction for class in a list

I'm trying to pull back a list of items that have a specific type of item in a set. For example: <class name="Owner" table="OWNER"> <id name="id" column="OWNER_ID" /> <set name="cats" table="OWNER_CATS" lazy="false"> <key column="OWNER_ID" /> <many-to-many class="Cat" /> </set> <class name="Cat" table="CAT" discriminator-v...

Paramaterising SQL in SSIS

Hi all, I'm trying to paramaterize some queries in SSIS. After some reading, it sounds like my best option is to create one variable that contains my base sql, another that contains my criteria and a final variable that is evaluated as an expression that includes both of these. I want to end up with an SQL query that is effectively ...

sql stored procedure in visual studio 2008

I want to write stored procedure in visual studio that as a parameter recieves the name of project and runs in database TT and copies data from TT.dbo.LCTemp (where the LC is the name of the project recieved as a parameter) table to "TT.dbo.Points" table. both tables have 3 columns: PT_ID, Projectname and DateCreated I think I have writ...