sql-server

Change font color for a column when the value changes

if i have a column where the values are repeated across rows and i want to change the color of the font when the value changes, how do i do this? ...

SQL Set Column Equal to Value

I have the following query. I need Description to be set to the value of the long statement in the middle - the part beginning with CONVERT and ending with [Description]. The query I have now runs but the value of Description in the result is always NULL. Any ideas? select s.SectionId, s.Academic_Year [AcademicYear], s.Academic...

XML Query Converting Group by field to child elements

I want the following query to return the fields in a parent child format. Is this possible? Here's the query SELECT Field1, Field2, Field3 FROM ATable GROUP BY Field1, Field2, Field3 ORDER BY Field1, Field2, Field3 FOR xml auto Here's what I would like to get back (doesn't...

SQL Server - need a SQL Query to identify/highlight specific changes in an audit table

Say I have some data stored in an audit table, where triggers on the main data table write all invoice record updates to this audit table. The audit table contains this data: InvoiceID CustomerID ItemSold AmountSold SalesPerson ModifyDate 1001 96 Widget 800 Robert 2001-1-1 1006 85 ...

Stored procedure to handle null parameter

I'm sure this has a very simple answer I am not finding... I have a simple hierarchy in a database where each row has a ParentId. If ParentId IS NULL, then it's a root element. I have the stored procedure: CREATE PROCEDURE GetByParent @parentId int AS BEGIN SELECT * FROM TABLE1 WHERE ParentId = @parentId END It works fine if I send...

I am trying to create this table in SQL Server 2008

CREATE TABLE DEPARTMENTS (Department_Id varchar(5) Primary Key NOT NULL, Department_Name char(20) NOT NULL, Manager_Id varchar(5) FOREIGN KEY REFRENCES EMPLOYEES, Location_Id FOREIGN KEY REFRENCES LOCATIONS) GO CREATE TABLE EMPLOYEES (Employee_Id varchar Primary Key NOT NULL, First_Name char(20) NOT NULL, Last_Name char(20) NOT NUL...

Split string in database row and copy results to different rows - SQL Server

Hello. I created an application to send mail to users. I'm using a database where some users have more than one email address assigned. Name Mail ----------------------------------------- BusinessXPTO [email protected];[email protected] The email column can contain more than one email, separated by a semicolon. I...

Correcting the SQL syntax?

Hi, Thanks very much for those responded. Is there a way in SQL server that takes the data from table1 and outputs the data like table2? Thanks! Table1: +---------+-----------+----------+------------------+ | Name | DOB | Agent ID | Agent Name | +---------+-----------+----------+------------------+ | subject | 4/20/196...

.Net Framework Installation

I had developed an application using .NET 2.0 and database as Sql Server 2005. When I installed my application in another PC, it asks for ".NET framework required". Is it important to have .NET Framework or else without .NET Framework shall we install ? ...

how to import flat file source to database using sql

hi. im currently want to inport my data from flat file to the database. the flat file is in a txt file. in that txt file, i save a list of URLs. example: http://www.mimi.com/Hotels-g303188-Rurrenabaque-Hotels.html im using the SQL Server Import and Export wizard to do it. but when the time of execution, it has error saying Error 0xc...

Sharing through Network ( INTRANET ) using .NET application

I am developing a winforms application using .NET 2.0 and Sql Server 2005. I want to just retieve the values from another PC from the Computer in which SqlServer Database is present. The appsettings that I have done in App.Config is as follows: <configuration> <appSettings> <add key="DatabasePath" value="Data Source=192....

SQL Server - Adding a string to a text column (concat equivalent)

How do you add a string to a column in SQL Server? UPDATE [myTable] SET [myText]=' '+[myText] That doesn't work: The data types varchar and text are incompatible in the add operator. You would use concat on MySQL, but how do you do it on SQL Server? ...

SQL request to list all databases in an instance of Sql-Server ?

Hello, Is there a way to list all of the existing databases in an instance of Sql Server via a SQL request ? More generally can I use SQL to fully read the schema of the databases (tables, columns, ..) ? Thank you Jerome Wagner ...

SQL Server transactions: insert causes locks?

I'm having the following issue: I'm inserting a row to table (say, 'temp') inside a transaction (default ADO.NET transaction). Until that transaction is committed, the command 'select * from temp', running from another session (SQL Server 2008 management studio), is blocked and cannot be completed. This seems weird to me. Shouldn't the...

1 stored procedure with flexible parameters, or many stored procedures?

Hi, I'd like to get your opinion on 2 ways of implementing the same stored procedure. Any advice would be greatly appreciated. Implementation 1 CREATE PROC GetFileSize(@Path varchar(500) = NULL, @FileID int = NULL) AS IF @Path IS NULL ' Find the file by @FileID and return its size ELSE ' Find the file b...

An object or column name is missing or empty.

I am getting the following error An object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Add a name or single space as the alias name. for the query show below: CREATE PROC [dbo].[Sp_T...

With AS error in SQL

i am getting the error as shown below : Msg 156, Level 15, State 1, Procedure Sp_Table1, Line 22 Incorrect syntax near the keyword 'AS'. while executing this SQL: WITH myCTE AS (Select mci.* from view_name AS si JOIN merch_catalog_ipt_view_name AS mci ON mci.view_id = si.view_id AND mci.resolved_view_name_id = si.view_name_id A...

Auto increment over multiple identity columns in MS SQL 2005 or 2008

Hi, I want to have two different tables in MS SQL, for example users and groups, both with identity column. It is possible to create auto increment over two identity columns? I want to have third table with common informations to these two tables and I want to identify unique record. In Oracle is SEQUENCE. It is possible to do it? Tha...

The multi-part identifier "si.shi" could not be bound.

i am getting the error as shown below : The multi-part identifier "si.shi" could not be bound. while executing this SQL: ;WITH myCTE AS (Select mci.* from view_name AS si JOIN merch_ctlg_ipt_view_name AS mci ON mci.view_id = si.view_id AND mci.resolved_view_name_id = si.view_name_id AND mci.ctg_ipt_event_id = @ctg_ipt_event_id ...

How to have Foreign Key Relation with a field that may contain Multiple Types of it?

Hello I am currently working on a DVD Store App. There are two tables in which I am having an issue. First is the Genres and the other is DVDCatalog. I need that DVD can be listed in one or more Genres. So, to do that I have to store like the IDs of the Genres (4,5,6). This way I can't make a relationship with the GenresID in the Genres...