Archived Months
January 2003
March 2003
April 2003
May 2003
June 2003
July 2003
August 2003
September 2003
October 2003
November 2003
December 2003
January 2004
February 2004
March 2004
April 2004
May 2004
June 2004
July 2004
August 2004
September 2004
October 2004
November 2004
December 2004
January 2005
February 2005
March 2005
April 2005
May 2005
June 2005
July 2005
August 2005
September 2005
October 2005
November 2005
December 2005
January 2006
February 2006
March 2006
April 2006
May 2006
June 2006
July 2006
August 2006
September 2006
October 2006
November 2006
December 2006
January 2007
February 2007
March 2007
April 2007
May 2007
June 2007
July 2007
August 2007
September 2007
October 2007
November 2007
April 2008


all groups > sql server programming > march 2007

Filter by Day: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

User defined regex function coded in C#
Posted by bdd at 3/31/2007 8:10:00 PM
Trying to create a function to regex through a SqlString data type. I am having problems casting or converting the sqlstring to a regex type. Here is the code: public static SqlString CF_SearchRegex(SqlString searchString) { string searchPattern = @"^(?<searchword>\w+)(?<there...more >>

Service Broker Question
Posted by scott ocamb at 3/31/2007 6:28:16 PM
I am building a service broker implementation. Our website allows a user to select a bunch of emails to send. These emails are send to a service broker queue. The receive queue executes an extended stored procedure written in C#. This proc performs mail merge work on the body and sends the e...more >>

How group a column to show side-by-side?
Posted by Ronald S. Cook at 3/31/2007 3:30:10 PM
This is nasty question but... How can I take the following data from a table: ID ItemNumber Type 1 9830302 CD 2 9830302 Cassette And run a select statement to get me: ID ItemNumber Type 1 9830302 CD/Cassette Thanks, Ron ...more >>

SQL 2005 Query Question
Posted by Spanky deMonkey at 3/31/2007 2:57:31 PM
In the Query Analyzer, when I use "AdventureWorks" I issued the query: Select lastname from person.contact The message states: Invalid object name 'Person.contact' When I issue the Query: Select LastName from Person.Contact I get results. Why is the query CASE sensitive? I looked ...more >>

Intelligent Product Search Query
Posted by Dan at 3/31/2007 2:38:04 PM
I need to create a better search on an ecommerce web site. Using the Northwind database as an example, here is what I need to be able to do. In Northwind.Categories.CategoryName, there is a value of "Dairy Products" In Northwind.Products.ProductNames there are 2 products with values of "Qu...more >>

Separating words from non-space string
Posted by Janusz at 3/31/2007 11:38:16 AM
Guys, I am trying to figure out how to program an efficient sql query for this scenario. Let's say I have a table with strings like that: thisismyexample , thisismyanotherexample, lastexample Then I have a table with dictionary words: this,is,my,example,another,last,..... (all the engl...more >>

Why this CTE error? What am I doing wrong?
Posted by cmay at 3/31/2007 10:07:32 AM
I can't get any CTE to work, even something this simple: WITH ASDF AS ( SELECT 123 as A ) Every CTE I try to create gives me the same error: Incorrect syntax near ')' for the final ")" Can anyone make a suggestion? ...more >>

Query help
Posted by David Trasbo at 3/31/2007 4:26:32 AM
I am still working on my instant messenger, but it's also going to include an RSS reader. The system is, that you need to subscripe the RSS feeds you want. If you add a new RSS feed to subscripe, it will be available for everybody in the database. I have the table 'RssFeedSubscriptions' whe...more >>



SQL 2005 Event Notification
Posted by LeifHar NO[at]SPAM gmail.com at 3/31/2007 3:01:44 AM
Hello, I want to log "DISABLE TRIGGER" statement. But as I understand and have read, this is not possible with event notification or DDL triggers. I believe I understand why not DDL trigger, but why not event notification? Is the only alternative to setup a trace that runs 24x7? Any sugg...more >>

How have strings within a string variable?
Posted by Ronald S. Cook at 3/31/2007 12:00:00 AM
This works fine: SELECT * FROM MyTable WHERE Code IN ('X', 'Y', 'Z') But I want those values in a variable. If I do the below, it doesn't work because the X, Y, and Z aren't their own string: DECLARE @MyString varchar(50) SET @MyString = 'X, Y, Z' SELECT * FROM MyTable WHERE Code...more >>

SQL Server and XML
Posted by SqlBeginner at 3/31/2007 12:00:00 AM
Hi All, I have an XML file for which I need to pass data from SQL Server. Sample xml file is shown below <Root> <One id="a"> <name>xyz</name> <url>Content comes from sql</url> <data>Content comes from sql</data> </One> <One id="b"> <name>xaz</name> <url>Content comes...more >>

dataadapter and dataset
Posted by yshie via SQLMonster.com at 3/31/2007 12:00:00 AM
visual studio 2005 ms sql server how will i know if i need to use a dataadapter and dataset? do i need to use them everytime i have sqlcommand? because i will create a data binding code and i don't know if i need to create dataadapter and dataset. i have 4 textboxes and i will fill only the...more >>

How to retrieve column value into a variable?
Posted by ~~~ .NET Ed ~~~ at 3/31/2007 12:00:00 AM
When I was into Oracle I used to be able to do things like "SELECT column INTO varname" and then use that variable into subsequent operations. I need to do something like that in SQL Server 2005 (Express). I have a table A with a PK and and several other columns. I am interested in a non-PK...more >>

How to avoid Redundant use of Costly View in Derived Tables
Posted by steventhrasher42 NO[at]SPAM hotmail.com at 3/30/2007 9:24:16 PM
I have a query that references a costly view as well as two derived tables that also need to reference the same costly view. The question is - is there a way to get this information back in one query while avoiding having to use the view multiple times? Perhaps SQL does not support this, and I...more >>

Best way to search one table based on another table's data?
Posted by Ronald S. Cook at 3/30/2007 6:01:01 PM
I have a table of keywords (hundreds/thousands of records): KeywordID KeywordName --------- ----------- 1 Apple 2 Orange 3 Pear I then have a table of products (also hundreds/thousands of records): ProductID ProductName ProductDescription -------...more >>

Job Schedule Help with UPDATE
Posted by Chamark via SQLMonster.com at 3/30/2007 5:49:08 PM
Newbie using SQL 2000 - First Job Schedule is failing - Need help. When I run this UPDATE query from the Table query pane I get this error message and when I click OK the query runs just fine. And the error doesn't come up again while I am in that session, only the first time I try to run the upd...more >>

BCPing Data into a table with more columns than are in the source data file
Posted by scudi54 NO[at]SPAM yahoo.com at 3/30/2007 5:02:38 PM
Sorry, posted this question on the SQLServer.Server group as well. Think this one is probably more suitable though. New to google groups. My apologies I have a table with 15 columns. However, in my data file I only have 9 columns. I have created a format file to map the data fields to the ...more >>

SQL query - table joined to itself
Posted by Claire at 3/30/2007 4:14:51 PM
database noob question. My User table refers to itself on one field. I have 3 types of user, and their UserType is stored in one column. The 2nd tier type of user "belongs" to a 1st tier user. 0st tier users are admins. So I have the following fields Users Table ======= Int64 RecID; // ...more >>

Need help finding most curr. yr. of acct. with most $
Posted by Marc Miller at 3/30/2007 3:47:39 PM
I've scratched my brain raw and searched the net. Maybe someone here will be kind enough to help. I have a table: Project Account Year Amount ABC 1234 1922 10.00 ABC 1234 1944 20.00 ABC 2234 1966 50.00 ABC 2234 1...more >>

Two single-quotes and null - aren't they the same?
Posted by tanya.wang NO[at]SPAM gmail.com at 3/30/2007 3:21:08 PM
Hi all, This is what happened last week - I tried to intentionally insert into a table with null values like this INSERT INTO Table1(ID, username) VALUES(xxx, '' ) while "username is the PK", ID is just a number with identity, and both ID and username do not allow nulls. Immediately I r...more >>

Update with Sub-Select
Posted by mnd3 at 3/30/2007 1:56:26 PM
Hi, this should be an easy one for most you people but it is eluding me. I am trying to do an update using a subselect and it errors out saying it doesn't like my ORDER BY. UPDATE(webapps.dbo.presidents_blog) SET archive = 'yes', archive_date = '3/30/2007 3:03:12 PM' WHERE topic_id NOT IN (S...more >>

Help on Nested views
Posted by lmsiva at 3/30/2007 12:56:01 PM
Hi, I have 3 views V1, V2, V3. I created a view V123, which combines three previous views. In the report I use the view V123. The report filters ( date and time and few more fields are applied only on the fields coming from V1 ). In this case, will the entire table used for the views V2...more >>

Query run through SSMS vs. ADO.net
Posted by DCPeterson at 3/30/2007 12:46:11 PM
We have a stored procedure that actually generates dynamic SQL and executes it. (It's a search function basically, so we don't know ahead of time which fields the user will want to search from...) Anyway, the most common search critera are @StartDate and @EndDate. When the stored procedur...more >>

Need help with SELECT
Posted by Terri at 3/30/2007 12:13:07 PM
How can I identify policies that do not have at least one associated account that is active? Desired results: C-Only associated account is inactive D-No associated accounts F-Only associated account is inactive CREATE TABLE #Accounts ( AccountID int, Active char (1) ) CREATE TABLE #...more >>

Data Type conversion from MS Access to SQL Server, problems with significant figures
Posted by bbcrock NO[at]SPAM gmail.com at 3/30/2007 10:59:39 AM
I'm new to working with numeric data that must be very accurate. We're converting data from MS Access though the original source data is still in Dbase IV and I can use that. A typical number looks like: 0.7854350 In Access I linked to the SQL Server 2005 database and wrote INSERT INTO b...more >>

DTS SQL JOB hangs even after the successful completion of the DTS
Posted by Query Builder at 3/30/2007 10:16:13 AM
Hi All, I have a DTS package that runs calling a few stored procedures and an activeX module. The package does some data cleanup and load. It takes an hour to complete. I have emails sent at the beginning and end of the package execution along with error notifications if any of the step fails...more >>

Valid Social Security Number in T-SQL
Posted by dba at 3/30/2007 10:05:14 AM
This works as a where clause in a query, but I'm trying to change it into a UDF to find valid social security numbers through SQL. I'm getting a syntax error and I'm not sure why? create function dbo.ufn_valid_ssn(@ssn varchar(11)) returns varchar(11) as begin (@ssn like '[0-9][0-9][0-9...more >>

Question RE: Triggers & non-auto incrementing keys
Posted by Dan Rolfe at 3/30/2007 10:04:11 AM
Hello all and I thank you in advance for your responses; Here is my scenario: I have table with a non incrementing identity field. I have built a website so multiple people can add information into this table simultaneously. The way my program looks up the next record is by scalar: select m...more >>

How to detect whether SMO is installed?
Posted by n7dai NO[at]SPAM comcast.net at 3/30/2007 9:46:33 AM
Hi, folks -- I am working on an install bootstrapper that (among other things) will install Server Management Objects (SQLServer2005_XMO.msi from SQL Server 2005 Feature Pack) iff it's not already installed. So, how to detect programmatically whether or not it's already installed? ...more >>

a query question
Posted by PamelaFoxcroft at 3/30/2007 9:44:01 AM
Hi I have a query which looks like this select * from tablename where col1='test' Sometimes in my queries I want to do this select * from tablename where col2='test' Now I want to wrap this in a stored procedure and I am curious as to what is the best way to do this, like this: cr...more >>

Replacing Coma during concatenation
Posted by Jami at 3/30/2007 9:03:33 AM
dear all if there is value null in first name or last name column then how can eliminate the coma that it should not come in the out put e.g if first name is Ali and last name is null then 'Ali' should b the output not ',Ali' how it can b possible SELECT LastName + ', ' + FirstName AS Mo...more >>

Complex Query Help!
Posted by Jami at 3/30/2007 7:58:49 AM
Dear All I have following query select Address = case when c.EngDesc = d.EngDesc and urban_rural = 1 then Address_details +','+ Locality+','+c.EngDesc when c.EngDesc <> d.EngDesc and urban_rural = 1 then Address_details +','+Locality+','+ d.Engdesc +','+ c.EngDesc wh...more >>

Rounding: round(x,2) gives 25011.790000000001 for 25011.799999999999
Posted by ErikYkema at 3/30/2007 7:57:14 AM
Hi, I am looking at a float field in a SqlServer2000 table. In the database I got the following value: 25011.799999999999. I like to export this to flatfile using DTS as 25011.80 or 25011.8 (rounding on two decimals). When rounding this using round(x, 2, 1), I get: 25011.790000000001 ! _Wh...more >>

Cursor endless loop
Posted by danielle.m.manning NO[at]SPAM gmail.com at 3/30/2007 7:54:58 AM
Hi all, I am hoping you can help me. I have a sql statement which returns three rows, which i am trying to use a cursor to loop through (yuck, i know! But this is the existing paradigm of the code I am in, and I don't want to change it drastically). The select statement I am working with cur...more >>

How to convert emails into data
Posted by Joel at 3/30/2007 6:50:01 AM
Bonjour! I would like to know if it is possible to have an application running on SQL 2005 that would wait for certain emails coming on it and than it would convert it into a row in a table. I want to create an application that people could send an email to the server SQL and it would co...more >>

Returning Data From One SP to another SP
Posted by S Chapman at 3/30/2007 3:59:02 AM
I have a stored procedure that executes a dynamic sql and returns rows. The structure of the results can vary (i.e. the columns returned are not fixed). I have a second stored procedure that woud need data returned by the first stored procedure but I can't figure out how I can receive the d...more >>

e_book
Posted by any_Girl at 3/30/2007 3:11:57 AM
hello I'm just a student & I'm looking for a nice helpful E_BOOK ...more >>

Using arithmetic operators for conditions in queries
Posted by Sudhakara.T.P. at 3/30/2007 2:22:00 AM
Hi, When I was browsing some site, I came across a query as follows: select a.*, b.* from a inner join b on a.field1 = b.field1 where (a.field2 (+)=b.field2). Could any one please interpret this for me or let me know the materials that I get to learn these techniques. I am eager to learn th...more >>

SELECT and UPDATE
Posted by simonZ at 3/30/2007 12:00:00 AM
I have very simple example. If I write select statement: select c.* from table1 c INNER JOIN table2 i ON c.warehouseID=i.warehouseID AND c.productID=i.productID I get 3 rows: warehouseID productID quantity ----------------------------------------- 1 'A' ...more >>

Variables & Results: Where vs. Join
Posted by Raterus at 3/30/2007 12:00:00 AM
Will there EVER be a difference in results returned between using a = variable in the join vs. using it in the where clause? Select * from mytable a left join anothertable b on a.col =3D b.col and = a.somedate =3D @somedate vs. Select * from mytable a left join anothertable b on a.col =...more >>

split address field
Posted by Craig at 3/30/2007 12:00:00 AM
Hi, I have a table with a field Address containing 1 string, but uses commas to distinguish between road, city, county etc. I need to build a view that has Address1, Address2, Address3, Address4, Address5. Is there a simple way to add to my select statement "SELECT FIRSTNAME, LASTNAME, ADDR...more >>

Dynamically create table name in TSQL
Posted by bubbles at 3/29/2007 10:28:44 PM
Newbie using SQL Server 2005 Enterprise: I need to dynamically create a TABLE NAME based on a variable @PRODUCT, but cannot seem to get it right. The table name has to be inserted into the TSQL statement location <Here_Is_My_Problem> DECLARE @PRODUCT NVARCHAR(35) DECLARE @NUM_ROWS I...more >>

Four table insert stored procedure SCOPE_IDENTITY
Posted by Sandy at 3/29/2007 6:54:02 PM
Can someone tell me what I am doing wrong in the following procedure? When I try to execute it, I get an error saying @LoanID was not supplied. Alter PROCEDURE InsertIntoFourTables -- For tblLoans @DateEntered datetime, @DisasterNo varchar(20), @DCMSNo varchar(20), ...more >>

Referring to comma separated values within a field
Posted by lesleyann76 NO[at]SPAM gmail.com at 3/29/2007 6:37:48 PM
In sql, in a given column I have records with information in them which is separated by commas (ie, 1,2,5,8,12) or (KD, K, DF) etc., yet it is all contained in one field. Well ordinarily when I evaluate the contents of a field I am familiar with referring to the object.column and generally look...more >>

Transaction issues
Posted by Ken at 3/29/2007 6:34:44 PM
I created stored proc which use transaction. It worked fine for updating, inserting, deleting. however, it didn't work correctly when I used for creating table. Any idea???? this is the sample for that. ================================= begin tran ken save tran ken Begin Try execute...more >>

locking question
Posted by Roy Goldhammer at 3/29/2007 5:07:06 PM
Hello there when i run Select statment on entire table. Does the table locked for other uses even for select part of the table? and when i run select statnent on part of the table. Does only that part is locked even for select? ...more >>

Performance Difference using tinyint instead of bit
Posted by ataylor NO[at]SPAM regonline.com at 3/29/2007 5:01:42 PM
Hi- We recently changed one table (200,000 records) to filter on a tinyint instead of a bit. We're experiencing a lot of timeout problems, but can't narrow down the cause. Does anyone have experience with a performance hit from filtering on a tiny int field instead of a bit field? Neither ...more >>

Question about temp tables
Posted by Roy Goldhammer at 3/29/2007 4:39:19 PM
Hello there If i just set SELECT INTO #tmp or CREATE TABLE #TMP INSERT #tmp where does the temp table is being saved? in the memory or in the HD ...more >>

Basic DB Design Question
Posted by Ryan at 3/29/2007 3:42:49 PM
Double Column tables (ID and Field).. should they be used? For example, lets say I have a Person table. Some attributes could be Ethnicity, State, EyeColor, and HairColor. If I want the user to have the ability to modify the available selections for those fields, the way I've done it in the...more >>

get DB access for an account?
Posted by Lynn at 3/29/2007 3:30:03 PM
Hi, I would like to design a procedure to dropuser and droplogin in database for terminated employee. Is there any exist script to use? Or How can I got the Database Access for an account without go thorugh each user database? Thank you for you help. -- Best Regards, Lynn...more >>


DevelopmentNow Blog