sql-server

How to skip date where holiday code = 1

Using SQL Server 2000 Table1 Date Holiday 23-02-2009 0 24-02-2009 1 25-02-2009 0 Table2 ID Date 01 23-02-2009 01 24-02-2009 02 25-02-2009 …, Here I want to skip the date where Holiday =1 Expected Output 01 23-02-2009 02 25-02-2009 How to make a query for this condition? ...

How to: usage-based performance optimization in SQL Server 2008 Express

How can I do usage-based perfromance optimization if I am running SQL Server 2008 Express and using SQL Server Management Studio Express? ...

how to rectify this query in Sql Server 2005

i have the a query which is union of two querries, the resulting query is bringing duplicate records, i dont want duplicate records, i tried putting DISTINCT but getting the same result, can anybody help me rectifying this query. i also want to know whether this query is safe from sql injection...i'll be pasting my query below: ALTER PR...

Joins in conditional statement in SQL Query

I have scenario like, I need to add my join in conditional e.g. When value is 1 then inner join to table a and if value 2 then inner join to table below is my sample query and I am getting error Incorrect syntax near the keyword 'inner' DECLARE @i INT=1 select name from emp if(@i=1) begin inner join a on a.ID=emp.ID end else if(@i=1)...

SQL Server authentication in SQL Server 2008

I created a login with SQL authentication credential in SQL Server 2008. But, I am not able to login using that credential. We followed the same steps in SQL Server 2005 and working without any problem. What could be the problem? Thanks, P.Gopalakrishnan. ...

comparing with dates?

Using SQL Server 2000 Table1 ID Name, Date, TimeIn, TimeOut, DateIn, Dateout AEAA00294 Alexander 13/10/2008 09:00:00 18:00:00 13/10/2008 13/10/2008 AEAA00294 Alexander 14/10/2008 16:00:00 02:00:00 14/10/2008 15/10/2008 AEAA00294 Alexander 16/10/2008 09:00:00 18:00:00 16/10/2008 16/10/2008 So on…, Table2 ID Date DATE, TIME, ID 20...

how to convert a numeric value into eng.words e.g 10 to ten in sql statement?

how to convert a numeric value into eng.words e.g 10 to ten in sql statement? ...

Very Slow Sql Server Query

I have 2 tables resulted from merging the following tables: Authors -Aid bigint -Surname nvarchar(500) -Email nvarchar(500) Articles -ArId varchar(50) -Year int -……Some other fields…… ArticleAuthors -ArId varchar(50) -Aid bigint Classifications -ClassNumber int -ClassDescription nvarchar(100) ClassArticles -ArId varchar(5...

Multiple SQL Server connection strings in app.config file

Hi guys, I'm interested in displaying in a Windows Forms app a list of N radio buttons for the user to choose a target database server. I would like to add the SQL Server connection strings in the app.config file, so they are read by the app at runtime and rendered in the windows form as radio buttons. At first I thought of using a de...

locating a flat file from SQL server 2005

I have built an SSIS job in visual studio 2005 that accesses a flat file and updates a table in SQL Server 2005. This works perfectly. I then store a copy on SQL Server by using the server storage option in the protection level property. When I try to run this it cannot locate the flat file. The flat file is located on a server and I use...

SQL Server: How to select multiple columns with 1 column being distinct?

I am trying to do an SQL query on two tables to retrieve multiple columns with a certain column (PostID) to be distinct (and it is not the primary key of the that table). In addition, I need the selected distinct rows to be the latest (one of the columns retrieved is the entry date). Detailed description: I am building a forum like ap...

Searching for data from one table in another table in t-sql (sql server2000) ?

Hey. I have table A. This table does not have any PK, it just stores lots of rows, which can only be identified by combination of its column values. There is procedure that takes data from table A, and from other tables, does proper matching/processing and feeds table B. Now, how do I check if data from table A is correctly inserted into...

Problem with DISTINCT, SELECT and SORT in TSQL

Hi there, maybe anyone can help me out with my SELECT statement on MS SQL Server. I am not very skilled in (T)SQL. I have a table called RECORDS and with a DATETIME column called [BEGIN]. Now I would like to get some nvarchars which look like this "December 08, January 09, February 09".. I came up with the following myself. SELECT DI...

Can BIRT pull out data from SQL Server?

I'm new to BIRT. I know it has a java based reporting engine. Can this engine talk to SQL Server and pull data? Thanx in advance. ...

Can I show both Simplified Chinese and English in the same web page?

I'm not a bad web developer but it happens that I've never had to support more than English in my web applications. Now it seems that I need to add support for Chinese for some folks in Shanghai. I was thinking, "I guess I'll just change my SQL database fields to nvarchar and I should be almost there." After doing some research, this ...

How to compare a date with system date?

Using SQL Server 2000 and VB6 Table1 ID Date 001 20090801 001 20090802 … 001 20090831 002 20090801 002 20090802 … 002 20090831 So on…, I want to compare a date with system date, suppose today date is 20090831, I want to display a message as “today is last day for 001” How to make a code in vb6 or is possible to make a query...

Should I rebuild table indexes after a SQL Server 2000 to 2005 database migration

I'm tasked with doing a SQL Server 2000 to 2005 migration. I will be doing a side-by-side migration. After restoring from a backup I plan to do the following: ALTER DATABASE <database_name> SET COMPATIBILITY_LEVEL = 90; DBCC CHECKDB(<database_name>) WITH NO_INFOMSGS DBCC UPDATEUSAGE(<database_name>) WITH NO_INFOMSGS exec sp_updatest...

Raise an error manually in T-SQL to jump to BEGIN CATCH block

Is it possible to raise an error in a stored procedure manually to stop execution and jump to BEGIN CATCH block? Some analog of throw new Exception() in C#. Here is my stored procedure's body: BEGIN TRY BEGIN TRAN -- do something IF @foobar IS NULL -- here i want to raise an error to rollback transaction -- do something next C...

SQL Server query - find first in sequence

Let's say I have the following example table GroupID ItemID Created ----------------------------------------------- A ABC 5/1/2009 13:02 A XZY 5/1/2009 13:01 A LMO 5/1/2009 13:03 A DEF 5/1/2009 13:00 A PQR ...

Differences when convert between Geometry & Geography instances

Hi there, Using SQL Server 2008: assuming I have a valid geography object geog1, converting it to a geometry instance geom1 (using the same SRID) and converting it back to an object geography geog2 shows no difference between geog1 and geog2. However, due to a problem already discussed here I cannot create a geography object containing...