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 > august 2004 > threads for tuesday august 31

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

Hexadecimal to Decimal Conversion
Posted by rgn at 8/31/2004 10:25:09 PM
Hello All, Would anyone know how to convert the hexadecimal value of the first & root column of the sysindexes table. I need the decimal equivalent as I would want to use DBCC PAGE to trace the Index Pages. Looks like I'm making a mistake as I get the following error when I convert 0x9E0...more >>


SQL don't like the subquery
Posted by Kenneth at 8/31/2004 9:14:16 PM
WHERE (tblTjanster.iKundID = @iKundID) AND (tblTjanster.iHsID = @iHsID) AND (tblTjanster.btAvslutad = @btAvslutad) AND tblTjanster.iKundTjanstID IN (CASE WHEN @iKundTjanstID = 1 THEN (SELECT iKundTjanstID FROM tblUsersMemberKundTjanster WHERE sUserID = @sUserID)ELSE @iKundTjanstID END) ...more >>

Check Constraint
Posted by Stefan Berglund at 8/31/2004 9:00:32 PM
Is it possible to specify in a compact fashion, a check constraint for SQL2K for a column which is VARCHAR(5) which can be any of the following where x is any number between 0 and 99 or blank and y and z are both any number between 1 and 99 but z is always greater than y? x y+ y-z -...more >>

Error entering <NULL> through Server Enterprise Manager
Posted by excelleinc.com at 8/31/2004 8:15:33 PM
Hi all, I'm kind of newbie in SQL programming and have a small problem. I'm trying to fill in test database through SQL Server Enterprise Manager. I opened a table, put some value into one of the columns and then I'm trying to get rid of that value and want it to be <NULL> (not blank). Ho...more >>

master.dbo.xp_fixeddrives
Posted by payyans at 8/31/2004 7:23:11 PM
SQL Server 2000 -------------------- master.dbo.xp_fixeddrives stored procedure is reporting different values when executed by 'sa' and a regular user. Results: (When executed by 'sa') drive MB free ----- ----------- C 18432 D 118784 E 16384 (3 row(s) affected) (W...more >>

Change the display text format
Posted by Devil Garfield at 8/31/2004 7:01:01 PM
Dear expert, I create a view as below: Code: Select Studn as NAME, Studs as SEX, Studca as [CHINESE ADDRESS], Studea as [ENGLISH ADDRESS] FROM Student_Record : : Screen Output: NAME SEX CHINESE ADDRESS ENGLISH ADDRESS ------- ---- --------------------- --------...more >>

User Define Functions- Incorrect syntax near '('
Posted by kumar at 8/31/2004 6:49:15 PM
Hi I have a UDF "fun " which takes 4 parameters and returns a table(col1,col2,col3) . --i was trying to execute the following code select A from dbo.fun ( parameter1, parameter2, (select count(*) from table1), (select sum(*) from table2 ) ...more >>

Counting consecutive dates
Posted by kelly NO[at]SPAM lexteq.com at 8/31/2004 5:45:25 PM
I've got a table that contains timesheet data (tablename is manhoursactual). I want to count the number of times that work is done on a given project each month. This is easy enough with the following query: select p AS ProjectID, t AS TaskID, count(p) AS Occurrences, DATENAME(month, w) ...more >>



Problem with point in time recovery
Posted by Jochen Daum at 8/31/2004 5:22:20 PM
Hi, I just tried to restore a "last night backup" to a point in time. The backup has been made at 2am. The transaction log backup has been made at 12:00 am My steps were: - Make a backup of the active transaction log - Restore the 2am full backup with NORECOVERY - Restore the active tra...more >>

bcp Field Terminator
Posted by Clint Colefax at 8/31/2004 5:05:03 PM
I am having an issue with bcp when I specify a field terminator while using the -w (nchar data type) switch. I am exporting data as a csv file so this can then be easily opened in excel. For this I need to specify a comma (,) as the field terminiator to override the default tab terminator. ...more >>

Compare large text problem
Posted by Hardy Wang at 8/31/2004 4:41:32 PM
Hi, I have a table with 2 text fields (A, B), I need to write a query, one of the condition is to list records which have different value of A and B. select * from table where IsNull(A, '') not like IsNull(B, '') When total number of characters is over 8K, query won't be able to run...more >>

Update using 2 tables
Posted by Mike at 8/31/2004 4:35:09 PM
Hi, I have 2 tables - main & temp, All I need to do is update the modified date of main where main.email = temp.email, I wanted to use joins but I got errors.I am not sure how to use joins in this case. This works - update Main SET modified_date='08/31/2004' where Main.email = Any(select ...more >>

Permissions problem when I use Linked Server
Posted by Anitha T at 8/31/2004 4:17:02 PM
Hi I wrote one stored procedure which accepts ServerName as parameter, then I used sp_addLinkedServer to connect that server and I wrote a query to return all databases ,users and their permissions information in that linked server. From the front end to connect to the database I am...more >>

change owner of a table
Posted by Terry at 8/31/2004 3:57:41 PM
In testing by development application, I backed up the real data base from the user's system, and restored it over by test database. In the course of development, I have been adding new tables. Inadvertently, the owner of one of the new tables is a user on the 'real' database, and when I restor...more >>

Query the Datatypes of the Resultset of a Stored Procedure
Posted by Eddy at 8/31/2004 3:53:09 PM
Hi I need to know the datatypes of the resultset of a Stored Procedure in the Microsoft SQL Server. E.g. The SP CustOrderHist of the database Northwind Call: CustOrderHist 'CACTU' Return: Productname = nvarchar(40) Total = smallint(2) Does anybody know how to do this? ...more >>

Initials
Posted by Just D. at 8/31/2004 3:25:48 PM
All, How can I get the string with Initials? I'm having for example 2 columns with varchar and I need to create a value for a new column with the first characters from these two columns if the strings in these columns are existing? Is it a simple way to do that? Regards, Just D. ...more >>

temp table?
Posted by ANN at 8/31/2004 3:20:20 PM
Please help...this is what I have so far... Creating a temp table to hold all the ids from table1 that match my criteria. Then would like to delete all the records in table2 that have that id(from the temp table), but I don't know how to do it??? THANKS!!! SELECT [ID] INTO #TempAnn FROM ...more >>

Newbie question on replace
Posted by moido10025 at 8/31/2004 2:53:13 PM
I am trying to replace a text string using like but can't seem to get it to work. SQL won't accept the first instance of like. What I have so far: update note set contact_1 like '%, %' where contact_1 like '%&%' Any help would be greatly appreciated....more >>

Design Considerations
Posted by Toby Herring at 8/31/2004 2:41:08 PM
I'm in a quandary. I have an application where one row of a table needs to be related to zero-to-many two-character state codes. One idea that has been brought up is to store all of the necessary state codes in a varchar field in a delimited format ('AK:AL:AZ') But this obviously violat...more >>

SQL Server 7.0 8k rowsize limit
Posted by SS at 8/31/2004 2:39:38 PM
Hi, Is there anyway to override the 8k rowsize limit in SQL Server 7.0 service pack 4.0. I have a Query with several nvarchar fields. The same query runs fine in SQL Server 2000. In SQL 7.0 it will return the message 2000 rows affected but there is no data. Is there anyway to bypass this probl...more >>

Problem with Attaching a SQL server 2005 detached database
Posted by bhagvan NO[at]SPAM gmail.com at 8/31/2004 2:00:34 PM
Hi, I was testing the Beta Release of SQL Server 2005, error when detach database from sql server 2000 -> i attached database to SQL Server 2005 -> detached it -> error when tried to attach to SQL Server 2000 Getting an error like Microsoft SQL-DMO (ODBC SQLState: 42000) Error 1831: C...more >>

Performance problems with application roles
Posted by isharko NO[at]SPAM yahoo.com at 8/31/2004 1:55:27 PM
We've been using Application Roles for more than 6 months. Up to few days ago it worked very well. Suddenly it got very slow. We tried to connect to DB in the old way (Windows only security) and it works great. I am trying to see what can I do to speed up the performance using AppRoles. ...more >>

Pattern Search Column using something like a regular expression
Posted by rogcorpr NO[at]SPAM hotmail.com at 8/31/2004 12:40:22 PM
I am trying to search a column using a pattern search but haven't found a solution and thought I would query the group for an answer. NOTE: I can't stored UDF's nor temp tables on the server. This has to happen in a single SELECT statement. Records are stored in a table field as: \\PR_MM31...more >>

Stored Procedure help
Posted by Viktor Popov at 8/31/2004 12:25:16 PM
Hi, I have a table Notify ------------ NotifyID int Primary Key UserEmail Varchar(64), EstateId int I would like to ask if someone knows how could be written a stored procedure which must do the following: 1. select UserEmail, EstateId from Notify 2. delete the rows which were in th...more >>

indexes count for each table?
Posted by ===steve pdx=== at 8/31/2004 12:14:23 PM
sql2k does anyone know a good select statement or one command line to display indexes count for each table in a database? thank you. ...more >>

Named Recordsets from SProcs?
Posted by A Traveler at 8/31/2004 12:13:55 PM
Hello, I have a SQL Server stored procedure which will return several recordsets back to the caller (multiple SELECT statements). By default when you call this stored proc from ADO.NET, you get back the tables in the DataSet as Table, Table1, Table2, etc.... Is there anyway in the sproc tha...more >>

Stored Procedure
Posted by Viktor Popov at 8/31/2004 12:00:11 PM
Hi, I have a table Notify ------------ NotifyID int Primary Key UserEmail Varchar(64), EstateId int I would like to ask if someone knows how could be written a stored procedure which must do the following: 1. select UserEmail, EstateId from Notify 2. delete the rows which were in th...more >>

Table Variables
Posted by Robert E. Flaherty at 8/31/2004 11:46:01 AM
On SQL Server 2000, can you pass a table variable as a param to a stored procedure as either input or output? ...more >>

Auto filling
Posted by Peter Osawa at 8/31/2004 10:57:11 AM
Hi, I'm new to MSSQL world and I have a little question: I have just added a new field to a table containing some 3000 rows... The new field has the same value for all the existent rows... How can I automatically update all rows ? I would like to put "EN" string in all rows... What to...more >>

CURSOR (FETCH FIRST or FETCH PRIOR) failed
Posted by Herve MAILLARD at 8/31/2004 10:17:10 AM
Hi, I use a cursor in my SP. I have no problem with the FETCH NEXT instruction but I don't know why, the FETCH FIRST and FETCH PRIOR always return -1 DECLARE OF_LIST CURSOR FOR SELECT num_cr_of FROM cr_of; OPEN OF_LIST FETCH FIRST FROM OF_LIST -- always return -1. works if I write ...more >>

SQL statement question
Posted by Rico at 8/31/2004 9:54:26 AM
I think i'm making this more difficult than it is, but i'm trying to get the following scenario to work: I have a single table of various project progress data: ID, Employee, Comments, EnteredDate, etc I want to pull the most recent comment for each employee assigned to a particular proje...more >>

SQL Syntax - CAST data type conversion & format
Posted by Bill Nguyen at 8/31/2004 9:28:34 AM
I would like to conactenate data from 2 numeric columns into a 3rd field with the following fixed format: XXX-XXXX Here's my syntax: update bfc_inv set export_itemcode = cast(dept as char(3)) + cast('-' as char(1)) + cast(item as char(4)) go The results are not very encouraging. I got ...more >>

Any way to get the equiv. of Q Anaylzer 'row(s) affected' in SQL?
Posted by Larry Woods at 8/31/2004 9:23:52 AM
Is there some "global" variable that contains the affected rows from a SQL execution? In other words, where is Query Analyzer getting the info for the response: '(x row(s) affected)' TIA, Larry Woods ...more >>

Do I need to use a cursor?
Posted by Kevin L at 8/31/2004 9:07:46 AM
I am not certain how to accomplish this task and would appreciate any suggestions with specifics. I currently have SQL script that inserts about 25000 records into a table. One of the columns is a "BatchID" column that is constructed using the current date and time (ex.- 20040830173520 (yyyy m...more >>

Computed Columns
Posted by rob at 8/31/2004 9:07:21 AM
Can a computed column use case logic ? Given two column X and Y can I create a computed column Z which basically says if column Y is Null populate it with X, else Y ? Thanks ...more >>

ADP/SQL Data Selection Criteria in a Stored Procedure
Posted by a1besw NO[at]SPAM ccbq.org at 8/31/2004 8:27:25 AM
I am using ADP front end and SQL on the back end. I want to run a report based on these 2 tables. Table1 Data: Client Id Date Employee ID Record Source 23376 1/9/2004 128 Table1 23376 1/8/2004 30 Table1 23379 1/6/2004 ...more >>

data in binary format
Posted by Mirna at 8/31/2004 8:18:07 AM
Hi, in one of the tables I have a column of image data type where data is stored in binary format (encrypted). Is there a way of converting it to text (something redable)? Thanks very much ! Mirna...more >>

Query Analyzer - Can you make a 'test run' on query?
Posted by Larry Woods at 8/31/2004 8:06:26 AM
I have various UPDATEs and INSERTs that I would like to "test run" before I execute them "for real" in order to at least see that them are touching the right number of rows. I have been burned in the past by executing bogus commands that have done real damage to my data and I would like to get s...more >>

Using variables in Dynamic SQL
Posted by robert.zirpolo NO[at]SPAM phoenixdb.co.uk at 8/31/2004 6:36:05 AM
When attempting to run the following query to generate and then execute dynamic SQL I am getting the error message "Syntax error converting datetime from character string." DECLARE @sql varchar(5000) DECLARE @StartDate datetime DECLARE @EndDate datetime DECLARE @Media nvarchar(500) DECLARE ...more >>

Recursively collect parent id column values
Posted by dotnw NO[at]SPAM hotmail.com at 8/31/2004 4:21:45 AM
Say I have a group of tables that are all related to each other in a nested tree like manner, where each table has a 'parent id' column that points you all the way up to the very top of the "tables tree". If I do a search at the bottom (leaf end) of the tables tree, is there a nifty shortcut w...more >>

Date value
Posted by Phil at 8/31/2004 2:08:08 AM
I need SQL to insert the date when a record is created, but it keeps reverting to full date & time (31/08/2004 09:54:23) - I only want the date, not the time. What do I need to do to get this to work?...more >>

How to "rotate" coulumns
Posted by Martin at 8/31/2004 2:05:13 AM
Hi, I have the following table: IDSupplier | Year | Sales ------------------------------------------------------------- 1 2004 12,5 2 2004 33,9 1 2005 11,5 1 2006 34,6 2 2006 39,8 .. . . .. . . .. . . My question: How could I "transform" the data to a structure l...more >>

Update / Insert Query
Posted by Peter Newman at 8/31/2004 2:03:04 AM
how can i get the following sample query to insert if 'licence' is not found, but only updatye if it is found update table1 set name = ' TEST' Where Licence = '123456' If licence 123456 exists then update name = 'TEST' and if 123456 is not found insert the record ...more >>

Still Struggling
Posted by jez123456 at 8/31/2004 1:19:12 AM
Hi experts I posted the 'dates in sql' question a while ago but it dosn't seem to have been replied to. I'm still having problems calculating vacation duration. Here is the test code I have so far. I’ve included data for decDuration to show examples of the correct values if vacation is...more >>


DevelopmentNow Blog