sql

Using custom codification scheme instead of GUID as Primary Key

I'm upsizing a backend MS Access database to SQL Server. The front-end client will remain an Access application for the time being (has about 30k lines of code). The aim is to eventually allow synchronisation of the database accross multiple servers (not using replication but probably the sync framework). Currently, all Primary Keys i...

Date Time Formating

Hi i need to wirte sql query in such a way that it will retrive the date in the following format dd MM yyyy HH mm ss AM(or PM) eg 31 12 2009 12 45 06 AN ...

how to transfer stored procedures between SQL Server 2005 databases

I'm creating web site on local computer. i'm using SQL Server 2005 management studio. I need to copy all data to destination server. Destination server is SQL Server 2005. My problem is when i using import/Export data for management studio, this only copy tables. when i using backup and restore, tables and stored procedure shows lik...

Cross Join

In SQL can anyone give me some good examples of when you would use a cross join? Duplicate Questions http://stackoverflow.com/questions/219716/what-are-the-uses-for-cross-join http://stackoverflow.com/questions/523091/sql-cross-join-what-use-has-anyone-found-for-it ...

ORACLE SQL function that can be used in the where part of a select statement

I would like to create a function that can be used in the where part of a select statement. Like this: select 'x' from table where addNumber(4,3)=7; I know how to do this in MS SQL, but I would like to do this Oracle SQL. How can I do this? ...

Quality of the autogenerated sql queries in Visual Studio

I was having an issue with the auto generated delete statement. In my mind the delete should have just been DELETE [tablename] where [PK] = @param but instead it generates a query with 4 ORs. DELETE FROM Market WHERE (@IsNull_Name = 1) AND (Name IS NULL) AND (@IsNull_Description = 1) AND (Description IS NULL) AND (MarketId = ...

Return sql query results in separate columns sorted vertically.

How can I rewrite the query "select col1 from tbl1" so it splits the results into three columns - each column sorting the results vertically? So if the data I'm getting back is: aaa bbb ccc ddd eee fff ggg I need the query to return it as: aaa ddd ggg bbb eee ccc fff Is this possible? Thanks ...

How to drop IDENTITY property of column in SQL Server 2005

I want to be able to insert data from a table with an identity column into a temporary table in SQL Server 2005. The TSQL looks something like: -- Create empty temp table SELECT * INTO #Tmp_MyTable FROM MyTable WHERE 1=0 ... WHILE ... BEGIN ... INSERT INTO #Tmp_MyTable SELECT TOP (@n) * FROM MyTable ... END The a...

Joining Information Across DB2 and Oracle Databases Best Practices

We are designing a fairly large brownfield application, and run into a bit of a issue. We have a fairly large amount of information in a DB2 database from a legacy application that is still loading data. We also have information in an Oracle database that we control. We have to do a 'JOIN' type of operation on the tables. Right now,...

Re-runnable SQL Server Scripts

What are the best practices for ensuring that your SQL can be run repeatedly without receiving errors on subsequent runs? e.g. checking that tables don't already exist before creating them checking that columns don't already exist before creating or renaming transactions with rollback on error If you drop tables that exist before cr...

Using LINQ to SQL with Dynamic tables

...

how to simulate session end event using sql session state in server farm

The session end event is not available when using SQL session state. We have an existing appication that uses this event, but we need to switch it over to SQL session state so we can set up a server farm for the application. We were hoping to use "sticky sessions" on the load balancer so we could keep using inproc session state, but were...

How do I extract duplicate records from a table using multiple fields?

I've already checked out the question http://stackoverflow.com/questions/633860/deleting-duplicate-records-using-a-temporary-table and it doesn't quite go far enough to assist me with this question: I have a table of approximately 200,000 address locations hosted on a SQL 2000 Server. This table has a huge problem with duplicate data in...

Inner joining UDF on SQL Server

Hello, i have a table valued function that does a complex query and returns a table (UDF1), and then I have another table that has a bunch of rows that can be used to reduce the output from this UDF Is it possible to join these two and pass columns from the table as arguments to the UDF ? like SELECT * FROM UDF1(TBL1.Column1, TBL1....

LDAP Modeling Best Practices

I am very in tune with relational modeling but new to LDAP modeling and am looking for best practices for designing LDAP schemas. Would love to know what are the equivalents of third normal form and other practices in the world of LDAP? Links to white papers that expand on this subject are greatly appreciated. ...

Dealing with duplicated data in SQL Server

I have a large SQL server table that looks something like this: ImageId int Page int FSPath varchar(256) ImageFrame int ... The table stores an entry for each page of a number of image files. This is done to enable the table to represent images where each page is represented by a different file, and multi-page image files that conta...

How do you search for a & (ampersand) in the tsql contains function?

I have a table T which has a column C which contains text that have the character & within it, but if I do the following query, it returns nothing, although I may have 10 rows. SELECT * FROM T WHERE Contains(C, 'a&b') ...

SQL Reporting: Null Parameter

I have discovered that in SQL Reporting there might be a problem. I have a ReportViewer on my page and I am sending in parameters using the following method: List<ReportParameter> myParams = new List<ReportParameter>(); myParams.Add(new ReportParameter("Start_Date", StartDate)); myParams.Add(new ReportParameter("End_Date", EndDate)); ...

Show a one to many relationship as 2 columns - 1 unique row (ID & comma separated list)

I need something similar to these 2 SO questions, but using Informix SQL syntax. http://stackoverflow.com/questions/37696/concatenate-several-fields-into-one-with-sql http://stackoverflow.com/questions/368459/sql-help-select-statement-concatenate-a-one-to-many-relationship My data coming in looks like this: id codes 63592 PE...

Why is SQL Server losing a millisecond?

I have a table structured like this: CREATE TABLE [TESTTABLE]( [ID] [int] IDENTITY(1,1) NOT NULL, [DateField] [datetime] NULL, [StringField] [varchar](50), [IntField] [int] NULL, [BitField] [bit] NULL ) I execute the following code: BEGIN INSERT INTO TESTTABLE (IntField,BitField,StringField,DateField) VALUES ('1...