Groups | Blog | Home


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
August 2008
all groups > sql server programming > may 2006 > threads for thursday may 18

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 definde global variable
Posted by checcouno at 5/18/2006 11:21:01 PM
Is it possible to difine a new global variable like @@MYVARIABLE accesible from all my stored procedure in my catalog? Thanks...more >>


exclude names that have numbers
Posted by Hassan at 5/18/2006 9:53:52 PM
Eg: Create table test (col1 char(20)) insert test values ('test') insert test values ('test1') insert test values ('te1st') insert test values ('tes') Basically I want the output to return those values that do not contain a number in the entire value.. So the output from above shou...more >>

Problem with convert
Posted by Rudy at 5/18/2006 7:23:01 PM
Hi! I'm trying to figure out this convert, never did one before. The SP I have I have I would like to add to a value. If 50 is in the credits column, and the new value is 25, then it should update to 25. Here is the SP. CREATE PROCEDURE dbo.NuCred (@UserID varChar(50), @Credits Money )...more >>

ARITHABORT
Posted by simonZ at 5/18/2006 7:09:25 PM
I have problem with indexed view: SELECT failed because the following SET options have incorrect settings: 'ARITHABORT' When insert, also some other options could affects. I can't change the server properties for all required options because it affects also other databases which are not...more >>

Copy SPROCs to different database
Posted by scott at 5/18/2006 7:06:01 PM
Is there a manual or code way to copy stored procedures from 1one sql db to another without opening each one, copying, creating a new SPROC in target db and pasting? Can DTS accomplish this? ...more >>

Set Identity_Insert On Linked Server
Posted by Derek Hart at 5/18/2006 6:17:52 PM
SQL 2000: OK, many problems with setting Identity_Insert on and off on a linked server. One problem is using the set command and getting the error "contains more than the maximum number of prefixes" when I do linkedserver.database.dbo.tablename - dynamic sql does not seem to work well at a...more >>

Returning all records that DO NOT contain a 4-character string...
Posted by whatageek NO[at]SPAM gmail.com at 5/18/2006 5:22:38 PM
Hello, I am trying to query a NTEXT field for a 4-character string and return only those records that DO NOT contain this string. I have converted the NTEXT field to VARCHAR for this purpose, but the query still returns records with the string. (NOT(UPPER(CAST(A.COMMENT AS varchar(8000))) ...more >>

Case null
Posted by Justin at 5/18/2006 4:46:00 PM
CASE(@CustomText) WHEN NULL THEN 'Status changed to ' + @StatusDescription ELSE @CustomText + ' ' + @StatusDescription END Now, @CustomText is either null or has value. WHEN NULL does not work. How do i get it to work? ...more >>



binary checksum like functionality in SQL Server 2005
Posted by cooltech77 at 5/18/2006 4:44:02 PM
Hi, I need to do the following. 1)Query a locally stored MS-Access table based on date. 2)Create 2 temp tables in SQL Server 2005 express edition(installed on local machine) called #yesterday and #today(which contain data for yesterday and data for today) 3)Compare each row and each colu...more >>

case null
Posted by Justin at 5/18/2006 4:43:16 PM
how do you deal with case null? CASE @test WHEN NULL THEN ........... ...more >>

Linked Server - Turn Off Constraints
Posted by Derek Hart at 5/18/2006 4:04:01 PM
I want to turn off constraints on all tables on a linked server using: "SP_MSFOREACHTABLE 'ALTER TABLE ? NOCHECK CONSTRAINT ALL'" Should I make a connection to the linked server, and/or use OpenQuery to pull this off? ...more >>

how to access MS Access table from SQL Server 2000?
Posted by cooltech77 at 5/18/2006 2:49:02 PM
Hi, I need to access a MS Access table from SQL Server 2000. Basically this is what I am trying to do. I do not have rights to create anything on the server except temp tables. So I read from the server's SQL table and copy data to MS-Access table on my hard disk. I append data to the M...more >>

checking for range
Posted by rodchar at 5/18/2006 2:35:01 PM
hey all, what's the best way to express this in a query? for each employee take the salary and determine which range the particular salary falls in. for instance: 40k falls between 35-40k so the category is 1 number of categories are 1-12 thanks, rodchar...more >>

BULK Insert
Posted by Sudhesh at 5/18/2006 2:13:32 PM
Hi, I have a stored prod that's doing a bunch of BULK INSERTs. The problem I'm having is if one the BULK INSERTs fails, then the rest of the stored proc isn't executed. I'd like it to proceed to the end and then I can take care of the failed section. I don't want any transactions here. T...more >>

Help with a Query
Posted by Matthew at 5/18/2006 2:07:38 PM
I am trying to get the following all into a single line, so i can run a larger Query and have a nice simple table listing all the SQL servies going on and when it was started. -TIA- CREATE TABLE #System_Monitor_Information_SQL_Information SystemName varchar(50) MSSQLServer varchar...more >>

Problem with numbering rows and repeating values.
Posted by rhaazy at 5/18/2006 2:04:41 PM
I AM USING MS SQL 2000 INSERT INTO #temp SELECT * FROM openxml(@iTree, 'ComputerScan/scans/scan/scanattributes/scanattribute', 1) WITH( ID nvarchar(50) './@ID', ParentID nvarchar(50) './@ParentID', Name nvarchar(50) './@Name', scanattribute nvarchar(50) '.' ) ...more >>

TSQL Cross-Tab query
Posted by Terri at 5/18/2006 1:37:19 PM
SQL Server 2000 I have a set of data and I want to build a SELECT statement that will return a single row in cross-tab format. Below is my sample data and desired results. Thanks to anyone who could help CREATE TABLE #TestCrosstab ( Account char(5), SubAccount char(3), Class char ...more >>

IF-ESLE TO Detemine WHERE Clause
Posted by Opa at 5/18/2006 1:30:01 PM
Hi, I have a SELECT statement whose WHERE clause depends on a condition. I want the following to work: DECLARE @condition bit .... (some code setting condition here SELECT FullName FROM Customers IF (@condition = 0) WHERE Deleted = 0 ELSE WHERE Deleted = 1 but this does not work. H...more >>

Duplicate rows
Posted by bic at 5/18/2006 1:05:01 PM
I am trying to clean up a set of a table where there are some duplicate data with different ids. What's the easiest way to eliminate the duplicate rows, for there are several hundred rows and only about 400 rows are unique. Thanks -- bic...more >>

Problems with my database creation script
Posted by javier.ignacio.villegas NO[at]SPAM gmail.com at 5/18/2006 1:02:50 PM
Hi, I have a strange situation. I must run the same script in SQL 2000 and SQL 2005. Basically the script does it: IF THE SQL SERVER IS SQL 2005, IT CREATES A NEW DATABASE AND USE IT, BUT IF SQL SERVER IS SQL 2000, IT MUST DOES NOTHING. USE master GO --// Create the DATABASE20...more >>

Linked Server
Posted by Derek Hart at 5/18/2006 12:57:51 PM
Is there a SQL statement that can detect if a linked server exists? ...more >>

Dynamic SQL Invalid Column name error
Posted by Shenoy.D NO[at]SPAM gmail.com at 5/18/2006 12:41:35 PM
Any idea why this is telling me that the field value I want to pass in is an invalid column name? This is for a "Search By" query. I have a drop down of choices and a text box for the value. I need to search for the value entered in the text box in the drop down field. The list is populated...more >>

can't delete a row from primary table - is there an SP for this?
Posted by Rich at 5/18/2006 12:01:01 PM
Hello, I copied a database from our live server to a test server where I could study the database, experiment and so on. I cannot delete/remove a row from the primary table. The table had several relationships, dozens of triggers, a constraint, and was under replication on the live serve...more >>

Problem with column prefix
Posted by rhaazy at 5/18/2006 11:58:44 AM
I have a rather complex looking sql statement and I've been debugging it for about a day now... So if the answer to my question is obvious forgive me. SELECT t.ScanAttributeID, t.ScanSectionId, t2.scanattribute, (select COUNT(*) FROM #dup, tblScanAttribute s1, #temp t1 WHERE #dup.attid = s1.S...more >>

Updating one-to-many table
Posted by Drew at 5/18/2006 11:42:47 AM
I posted here 2 days ago about finding the most recent row in a one-to-many table. My query for that looks like this, select * from Admissions c join (select RegNo,max(AdmissionNo) As AdmNo from RecordSummary group by RegNo) as RecSum on RecSum.RegNo =c.RegNo order by c.RegNo I would l...more >>

How do I force upper case in a select statement
Posted by Thirsty Traveler at 5/18/2006 11:24:12 AM
I want all of the columns in a select statement to be converted to upper case. What is the proper syntax for that? ...more >>

Query to sequentially number Null fields in a column
Posted by Matt Williamson at 5/18/2006 11:10:54 AM
I'm trying to write a Query that will Update all the Null fields in Table1 column1 to 'P' and a 6 digit sequential number starting from 000001 including the leading zeros. Can someone help me figure out the correct syntax? So far, nothing I've come up with is working right. TIA Matt ...more >>

T-SQL
Posted by MS User at 5/18/2006 10:53:01 AM
SLQ Server 2000 I have a table 'Route' with schema CREATE TABLE [dbo].[ROUTE] ( Carid integer not null, seq_num integer not null, State char(30), City Char(30) ) Sample Data (This table can have any number of records for a given Carid) insert into route values (100,1,'AA', 'City1') ...more >>

stuck on dynamic sql generation
Posted by Akimeu at 5/18/2006 10:48:52 AM
Hello group, We are trying to create a dynamic procedure that will allow us to copy all the FK DDL generation into a temporary table, drop all the FK's, truncate all the tables, then recreate all the FK's. I tried searching for a solution, and couldn't find an answer (besides the sp_MSFo...more >>

Ordinance
Posted by John Smith at 5/18/2006 10:41:18 AM
I have a bunch flat files that I load into a temp table daily for processing before inserting into a mater table. The flat file is in sequential order as follows (Header row then below its detail rows) RecordType Col1 H Some Header Text 1 D ...more >>

UPDLOCK blocking readers
Posted by James Hokes at 5/18/2006 10:39:16 AM
Hi, SQL 2000, SP3a According to BOL, UPDLOCK will not block readers. However, if I do the following: 1.) Open Query Analyzer 2.) BEGIN TRANSACTION 3.) SELECT * FROM MyTable WITH(UPDLOCK)WHERE (Col = 'Predicate1') 4.) Leave this window open, with the open transaction 5.) Open new query ...more >>

Break Apart Data Using While Loop
Posted by Anonymous at 5/18/2006 10:35:02 AM
I need to break apart the following data into multiple records but I am not sure how to write the code. The record identifier is the ; RecordID DataInfo 1 "abc", "def"; "ghi", "jkl" 2 "abc", "def", "ghi"; "jkl", "mno" Data in a new table will ...more >>

applied dts files to sql server
Posted by Kevin at 5/18/2006 10:35:02 AM
I have a file named "posting.dts" in my c:\test\ directory, how do I write a script to apply this dts package to SQL server "server1"? thanks ...more >>

simple trigger question
Posted by Tim at 5/18/2006 9:24:39 AM
hi, being new to triggers I'm sure this is an easy question for you... I have a table. When a record is updated or inserted I want to check a field value. If the new value matched some criteria I want to send an email. This is what I have so far... ----------------------------------------...more >>

UDFs - what resources used?
Posted by smithabreddy NO[at]SPAM gmail.com at 5/18/2006 9:20:51 AM
Several stored procs get a string of IDs which are then placed in a temporary table, and later used in SELECT queries to retrieve matching rows from other tables. ----------------- Example: CREATE PROCEDURE dbo.Select_Companies @IDs ntext as begin CREATE TABLE #companies ([Compan...more >>

Ranking Rows
Posted by rhaazy at 5/18/2006 9:11:53 AM
Instead of explaining my example I took the one that i used to get as far as I am now to demonstrate what the task is I'm trying to complete. Consider the following: CREATE TABLE #teams ( city VARCHAR(20), team VARCHAR(20) ) SET NOCOUNT ON INSERT #teams SELECT 'Boston', 'Celt...more >>

drop and create constraint
Posted by Ganesh at 5/18/2006 9:11:01 AM
Hi There, I've to alter the default constraint, So i drop then create agains. Before applying this changes to all database, do i need to tell users to log off. or will it work even they are connected to the system -- Thanks Ganesh...more >>

User Defined functions - what resources get used?
Posted by smithabreddy NO[at]SPAM gmail.com at 5/18/2006 9:02:54 AM
Several stored procs get a string of IDs which are then placed in a temporary table, and later used in SELECT queries to retrieve matching rows from other tables. ----------------- Example: CREATE PROCEDURE ExSp.Init_Companies @IDs ntext as begin CREATE TABLE #companies ([CompanyID] [in...more >>

ADO.NET Timeout Exception - I have tried everything
Posted by sorcerdon NO[at]SPAM gmail.com at 5/18/2006 8:46:11 AM
Hello! I am looking for someone who has solved this multi-million people's problem. EVERYONE seems to ahve this problem. Im a creating a data set and populating it with a call to a store proc. Its a complex stored proc with the end result as an insert to a temp table. Then I do a select fro...more >>

Wrong result set in derived table query...only on sql server 2005
Posted by sandroargiolas NO[at]SPAM tiscali.it at 5/18/2006 8:23:57 AM
This query run on sql server 2000 but doesn't work on sql server 2005: select * from (select * from inventory where (description like 'Ram%') ) drvtbl where convert(integer,isnull(value,0)) > 273000 This is the table Id description value ------------------------------ 1 Operatin...more >>

Convert(datetime, '07/11/48') Returns Year 2048!!
Posted by crferguson NO[at]SPAM gmail.com at 5/18/2006 7:50:33 AM
Hello all! I'm having some issues trying to convert a varchar string into datetime. What I'm wanting to do is take the string '07/11/48' and convert it to datetime, i.e.: 1948-07-11 00:00:00.000, but the convert function is returning 2048 as the year! The function I'm using is: SELECT CON...more >>

advantages of Identity Column
Posted by mavrick_101 at 5/18/2006 7:18:01 AM
Hi, What would be possible advantages of having Identity column as primary key than having another unique column as primary key.? ...more >>

I'm not sure why this one fails,
Posted by Jay Bukstein at 5/18/2006 7:03:02 AM
I used the following SQL to extract data from our Firms emplyee database and creates a text file that gets imported into our copy machine controllers. Output lines look like this: A|U|4111|MPLS, PBMS|01|0|| A|U|4222|RIC, PBMS|06|0|| A|U|2036|user, name|01|0|N|1234562| The last number is t...more >>

TSQL copy data from one table to another and inserting @@identity
Posted by postings NO[at]SPAM alexshirley.com at 5/18/2006 6:24:09 AM
Hi I'm stuck on a TSQL statement in SQL Server 2000. Basically I want to copy data from CustomerAccountsTable into Contacts table. At the same time I want to retreive the primary key value autogenerated from the newly inserted row and put that value back into the CustomerAccounts table (Co...more >>

Long Where
Posted by Anne at 5/18/2006 5:35:42 AM
I have a long where statement. Is there a way to reference all the fields with one name and then use this further down in the sql statement instead of repeating all the fields? Thanks in advance ...more >>

Two Primary key ranges
Posted by hals_left at 5/18/2006 5:05:39 AM
Hi , I have a web based sql sending data to an internal sql server and then using bulk insert. I ned to ensure record ids are preserved and prevent duplicates. Is it possible to maintain two distinct ranges for primaruy keys in one table? For example I want the web based records ids to start a...more >>

Changing the collation of a server
Posted by Peter Newman at 5/18/2006 4:35:01 AM
When the SQL 2005 server was set up , the collation wasnt set correctly. A lot of tables have been created by using import wizard from a dev server, I am now getting a lot of errors on all my Queries; Cannot resolve the collation conflict between "Latin1_General_CI_AS" and "SQL_Latin1_Ge...more >>

Problem with complicated CASE
Posted by Cartman at 5/18/2006 2:32:32 AM
Hello. I have a big problem which may be easy for some one who did it before. I'm trying to write a view with embedded Cases. Resp = CASE WHEN (case WHEN [FixVndr]is null THEN (case when [Material] is null then [PurGrp] else [MRP]) ELSE (case when [FixVndr]<9999 then [...more >>

filtering records at source using OpenRowset
Posted by Nabeel Moeen at 5/18/2006 2:19:01 AM
Hi, I have a lot of reports on MS Access which consolidate data from various sources using linked tables. I'm planning to move the reports to some other platform (preferrably Crystal reports) and was planning to use SQL server as the target DBMS. To consolidate/fetch data from other sources ...more >>

how to replace NULL values in a query?
Posted by pedestrian via SQLMonster.com at 5/18/2006 2:01:10 AM
I'm using MS SQL Server 2000. I have a simple table (Table1): Table1: ID Name PostCode 1 James 12345 2 Mandy 99100 3 John NULL 4 Alex NULL how to build a query that list all Table1 data replace those with PostCode NULL with Postcode '00000' ? Result expected: ...more >>

Values longer than 255 chars (a novelty in SQL 7) are truncated to
Posted by gunman at 5/18/2006 1:12:02 AM
I am making a program using DB_Library. But now i encounter a question. that is, IN database a char column is presented, and the max-length is more than 256 ,is 400. I get the value using dbdata function, however, the result is always 255. and i know that As strings. Values longer ...more >>

IDENTITY_INSERT Error
Posted by Peter Newman at 5/18/2006 1:12:02 AM
I have been trying to get this to work but am failing can anybody help SET IDENTITY_INSERT bossdata.dbo.DailyOverLimits ON INSERT INTO bossdata.dbo.DailyOverLimits SELECT * FROM OPENDATASOURCE ('SQLOLEDB', 'Data Source=@Server;User ID=@UserName;Password=@Psw' ).Bossdata.dbo.Dail...more >>

Collation Danish_Norwegian_CI_AI
Posted by RichardH at 5/18/2006 12:20:02 AM
Hi, We have some problems with the fact that SQL Server reads "aa" and "Ã¥" as the character. I use the Danish_Norwegian_CI_AI collation on the table. First i'd like to find a good chart of the different collations? Secondly I'd like to know if someone knows a good way a round this? Th...more >>

**case cluase**
Posted by R-M at 5/18/2006 12:00:00 AM
Hi I'm working with SQL2000, and I want to have a following result I tried it with case clause but I couldn't get the desired result. Table1(code1,date1) I want to check the variable @status if it's 0 then I want to fetch all rows without any condition but if it's 1 then I want the range ...more >>

sp_columns
Posted by Hoosbruin at 5/18/2006 12:00:00 AM
Sql7.0 sp4 Old N/T 4 machine I have a VB(6) app that accesses the DB thru and ODBC(system DSN) connection. It only uses a few SP's in the code and the rest inline SQL statements. When I turned on Profiler I noticed calls to sp_columns with a TableName as the Apps running. They complain the...more >>

want to make a single query
Posted by imtiaz at 5/18/2006 12:00:00 AM
how can i combine and make the the following to a single query? --------------------------------------------------------------- insert into #RegionPeriod select PeriodCode from tblRatesHeader where AllMarket=1 insert into #RegionPeriod select PeriodCode from tblRatesHeader r,tblProductMaster P...more >>


DevelopmentNow Blog