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 > april 2006 > threads for friday april 21

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

Right way to do a insert
Posted by Michael Fällgreen at 4/21/2006 10:28:39 PM
Just to make sure - is this the right way to do a simple insert? Create PROCEDURE dbo.spInsert( @name varchar(50)) AS begin tran set nocount on insert into tbl (name) values(@name) set nocount off declare @id int set @id = @@IDENTITY commit tran return @id ...more >>

How do you reduce the size of the Log File when using SQL Server 8?
Posted by RonL at 4/21/2006 7:14:38 PM
I'm using SQL Server 8. My test database is 2.5 gig but my log file is now 30 gig. I'm using all the default settings and I guess it's been just increasing until it nearly filled up my HD. Is there an equivalent of "Truncate on Checkpoint"? I've tried checking "auto shrink" and backing up and re...more >>

Join using LIKE ?
Posted by Martin Harran at 4/21/2006 5:29:48 PM
I have been given two tables in Excel which I've imported into SQL Server and I need to join them. Each of them has a unique Product but there is a bit of inconsistency in that in Table A, some (but not all) of the Products have been prefixed with the Supplier Name - I don't have a master ...more >>

GROUPING problem
Posted by David at 4/21/2006 5:03:36 PM
I am trying to get counts of jobs accum into 4 columns by date. When I try to save the view it gives me the error "Column 'dbo.RepairOrder.JobSize' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause." I don't want to group by Jo...more >>

how to select distinct rows problem?
Posted by Rich at 4/21/2006 4:30:01 PM
create table tbl1( fname varchar(10), lname varchar(10), item int ) insert into tbl1 select 'joe', 'smith', 1 union select 'joe', 'smith', 2 union select 'joe', 'smith', 3 union select 'bill', 'jones', 4 union select 'bill', 'jones', 5 union select 'bill', 'jones', 6 union select 'sam'...more >>

Null data source to default value
Posted by microsoft.public.dotnet.languages.vb at 4/21/2006 3:50:14 PM
Hi All, I have the following situation. I am trying to populate data in a table from other tables. Say table1 has default values in all fields. But the data is coming from joining table2, table3, table4 and so on joined in a single query. Some of the fields of tables' table2, table3 and t...more >>

A stored-procedure becomes slow and needs re-creation
Posted by Boaz Ben-Porat at 4/21/2006 3:46:16 PM
Hi all I have a SP that beahves strange. Originally it takes about 20 milliseconds to complete, but sometimes it starts going slow and take about 5-7 seconds. When this happens, it keeps going slow until I drop the SP and re-create it. I tried to run the SQL body of the SP in the Query ana...more >>

LoadFromSQLServer method has encountered OLE DB error code 0x80040E09 (EXECUTE permission denied on object 'sp_dts_getpackage',
Posted by Kim at 4/21/2006 3:45:53 PM
I am trying to execute an ssis package from the web - classic asp page I am using windows authentication to login to the web site which I assume means i am executing the package under that account That account being administrator I am using the code below to execute Dim objWshShell...more >>



TSQL for date of next weekend
Posted by Matt Jensen at 4/21/2006 3:22:19 PM
Hi I need to calculate the date of the next weekend (so either Saturday and/or Sunday's date) from getdate() inclusive of if getdate() is a weekend-day. I need to filter some realtime travel related data for "this weekend" via SQL. Anyone got any neat ways of doing this? Cheers Matt...more >>

Login failed State 16 SQLServer 2005
Posted by astaylor at 4/21/2006 3:21:07 PM
Using SQLServer 2005 I create a new database with code from my Windows application. Then I launch osql to create tables from a script. This works fine. Next I try to insert a row into one of the tables and I get: Login Failed. Error: 18456, Severity: 14, State: 16. If I pause for 5-1...more >>

BULK INSERT permissions for non-admin?
Posted by Jesse at 4/21/2006 3:13:30 PM
I've got a user, "joe", logging into a SqlServer 2005 database using sqlserver authentication. Joe can create tables, insert, select, drop -- whatever -- but when he tries to do a bulk insert, he gets: "The current user is not the database or object owner of table 'myTable'. Cannot perform...more >>

SQL2005 and 4GB of RAM : How do I use it?
Posted by Russell Mangel at 4/21/2006 3:12:40 PM
What exactly do I need to configure on my SQL Server 2005 to use more than 2GB of RAM? Currently the Server Properties is only showing ~2GB and I have 4GB installed. There seems to be a lot of conflicting information (from Google). I have: Windows 2003 Server Standard. Using 4GB of RA...more >>

How do I link tables to another database?
Posted by 0to60 at 4/21/2006 2:44:39 PM
With Access, I could link to tables in a foreign db, even a csv file, and query them as if they were local tables. How do I do that in SQL Server? ...more >>

Top 5 Quesiton
Posted by dTHMTLGOD at 4/21/2006 2:39:12 PM
I have a SQL table with a 2,000 + records. I need to pull the top 5 problems from each office. The fields in the tables are Office, Problem (TypeItem below), User. My queries right now only pulls the top 5 from the table (see below). I would like to pull the top 5 from each office. Th...more >>

Trigger Security
Posted by Todd C at 4/21/2006 1:28:02 PM
I have a Payments table with a trigger that fires on Insert and Update. It has been working fine for the past few months. Now, it disconnects the user from the db whenever it fires. However, if I, as a sysadmin, modify data in the table, the trigger fires OK and does what is supposed to do. I ...more >>

problem with select * from [remote server] in QA
Posted by Rich at 4/21/2006 1:28:01 PM
In Query Analyzer connected to my local server using Windows authenticatio I tried to run this select statement against my remote server: select * from [11.22.333.444].remoteDB.dbo.tbl1 I got this error: "Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server con...more >>

Use UDF which returns a table in a join
Posted by BF at 4/21/2006 1:12:02 PM
I have a UDF, dbo.ContractSummary which takes one parameter ContractID and returns a table. I want to use this UDF in a SQL select statement like this: SELECT cs.* FROM Contract c JOIN dbo.ContractSummary(Contract.ContractID) cs ON c.ContractID = cs.ContractID But I got error message c...more >>

Inserting data into a table which already has identity
Posted by Alex at 4/21/2006 1:08:24 PM
Hello all, I have two tables, I'll say Table A and Table B for the example, where Table A has all my data and Table B is blank but has the same layout as Table A except it has an additional Identity field setup to create an ID field. I want to Import all the data from Table A to Table B, bu...more >>

Doing the lookup on the server while inserting
Posted by sklett at 4/21/2006 12:51:06 PM
I have these 2 tables: CREATE TABLE tbl_ft_testsegments ( SegmentID int(10) AUTO_INCREMENT NOT NULL, TestID smallint(6) NOT NULL DEFAULT '0', CarrierFreq smallint(6) NOT NULL DEFAULT '0', BeatFreq smallint(6) NOT NULL DEFAULT '0', BeatFreqDelta ...more >>

Get Today's Records
Posted by Pancho at 4/21/2006 12:48:02 PM
Hello, I have a query that needs to run daily and only collect records for that day's activity. The table has a date/time field called TranDateSold. Could someone please advise the proper syntax for the following logic: SELECT * FROM tablename WHERE TranDateSold (is today only) I experiment...more >>

I am getting an error in creating a simple store procedure!
Posted by Learner at 4/21/2006 12:46:28 PM
Hi , Here is my stored proce and I am not sure why its complaining about the below error SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE PROCEDURE [dbo].[USP_InsertUserInfo] @aspnet_userid uniqueidentifier(50) ,@DealershipID int ,@LastName va...more >>

Quick Stupid Question, One to One Relationship Storage
Posted by Matthew at 4/21/2006 12:32:23 PM
On one to one relationships data will only be inserted into the second table if that information is provided. That is it doesn't place a bunch of null values just because you added and item to the first table but do not define any values to the second table, there by the first table can have tho...more >>

Stumped on filtering data by date
Posted by jmawebco at 4/21/2006 11:31:10 AM
I have a stored procedure that selected records from one table and inserts them into a second table based on some criteria. What I want to add is filtering by "Today -1". The problem I am having is that the date field being looked at is formated as yymmdd. Can anyone help me out in trying to fig...more >>

Msg 226, Level 16, State 6, Line 4 ALTER DATABASE statement not allowed within multi-statement transaction.
Posted by RSH at 4/21/2006 10:40:30 AM
Hi, I am trying to execute a simple statemnt that I got right out of books online and I keep getting this error and I cant figure out what Im doing wrong: ALTER DATABASE [00057088] SET SINGLE_USER WITH ROLLBACK IMMEDIATE Msg 226, Level 16, State 6, Line 4 ALTER DATA...more >>

Sub Query ?
Posted by HeartSA at 4/21/2006 10:39:55 AM
I have a table in SQL Select Count(*) AS CountAll from Data Select Count(*) AS CountSome from Data where Individual = Name I would like to combine this into one statement and give me both the CountAll and CountSom ...more >>

Stumped on an Update Query
Posted by Mike Voissem at 4/21/2006 10:04:02 AM
I have an update query that I'm trying to resolve, but I'm at a lost as to how to accomplish this. I have two tables(Orders and Mailings). I need to update an Orders field with a field from Mailings. There are some that will have a one-to-one relationship, and others will have many-to-many,...more >>

Copy users between databases
Posted by Terry at 4/21/2006 9:58:30 AM
Hello All, I used DTS to copy one database to a blank database for a backup of the database. A duplicate database. How do I copy over the user logins to the new database. This did not happen with DTS. The databases are on the same instance of SQL. Any help appreciated. Thanks, Terry...more >>

How to best handle multiple parameters?
Posted by Phill at 4/21/2006 9:32:02 AM
I am preparing the write a sp that will accept about 20 optional parameters that will filter my resultset. Since these are optional I was thinking that I needed to dynamically build my query string based on if a parameter had a value. This seems inefficient so I was wondering if there is a b...more >>

BLOBs and Stored Procedures
Posted by Tony HADM at 4/21/2006 8:57:02 AM
I have been told that using BLOBS and Stored Procedures is a bad thing. Running the SQL in the page is the only correct way. We are using SQL Server 2000 - soon to go to 2005. Could someone direct me to documentation that addresses this situation? -- Tony...more >>

Stored Procedure generating error
Posted by Jesusluvr at 4/21/2006 8:51:02 AM
I am trying to compile this procedure and run it. It compiles fine, however when I run it I get the following error: (1 row(s) affected) (1 row(s) affected) Msg 203, Level 16, State 2, Procedure ETL_CC_TBL_CUSTOMER, Line 96 The name 'CREATE TABLE CUSTOMER_DELTA_A ( ...more >>

Complex View creation question
Posted by William Sullivan at 4/21/2006 8:17:02 AM
I need to create a cross-database view (same server) in a master database. The databases I'm joining in the view are listed in a table in that master. I'd like for the view to automatically include new databases whose names are added to that table in the master. How would I go about doing t...more >>

Calling Stored Procedure from asp without waiting
Posted by Anne at 4/21/2006 8:16:41 AM
Hi, I'm developping a asp application that somestimes needs some heavy synchronisation done. I wrote a stored procedure for that purpose witch takes approximatly 15 minutes. Right now I run this directly on the server (using MS SQL Server management studio). But I would love to be able to cal...more >>

How-To create a "Dirty" Stored Procedure (Relates to Transaction)
Posted by Mathieu Dumais-Savard at 4/21/2006 8:14:34 AM
I explain: I have created a stored procedure that indicate the status of an ETL... I call it like this: 0- BEGIN TRANSACTION 1- --Updating LOG Status 2- exec update_etl_status 'Main Table','Transforming' 3- update Stg.[Main table] ... blablabla 4- 5- -- Updating LOG Status 6- exec updat...more >>

Use float or decimal to get time?
Posted by sdblonde63 NO[at]SPAM iwon.com at 4/21/2006 8:06:25 AM
I'm a newbie, and I need to convert a time interval of seven position numeric field from a flat text file in format MMMMSST and store in a database with the tenths of second in first position after the decimal. The current stored proc uses the following float method and I was thinking it would ...more >>

Any way to query EXECUTE perms on stored procs?
Posted by PSPDBA at 4/21/2006 5:40:38 AM
I've recently been tasked with duplicating the permissions from one account to another. We have a development, system test, and production SQL Server, and approximately 35 databases in each. We use a fine level of control on this particular account because it's what the applications use to log...more >>

Multiple queries SQL
Posted by Ames111 at 4/21/2006 4:02:34 AM
Hi my first post!!! i have an organisation table and i want to do something like this select count(orgname) as Count1 where orgname like 'A%' select count(orgname) as Count2 where orgname like 'B%' but i want it to list every organisation, so one on each row, then the 2nd column show t...more >>

Interesting Query
Posted by S Chapman at 4/21/2006 3:43:14 AM
I have four lookup tables that have identical structure. I have to write a query to check if a particlaur string (code) exists in any of the four lookups. What is the best way of dealing with this please? 1. Write one query with four corelated subqueries (one for each lookup). 2. Write 4 ...more >>

security for row level but not based on Database user's login
Posted by Friends at 4/21/2006 3:26:22 AM
Hi I need to set security for row level but not based on Database user's login. It should be based on the user table login. For the particular user I need to allow only the particular records to access insert, update delete and select. Let me explain clearly For example think we are usi...more >>

service broker management views
Posted by Mana at 4/21/2006 3:02:22 AM
According to msdn the views 1.sys.dm_broker _forwarded_messages returns a row for each Servive Broker message that an instance of SQL server is in the process of forwarding, and 2. sys.dm_broker_connections returns one row for each Service Broker network connection. But when I do "Select" ...more >>

Why does (SqlInt32)sqlCommand.ExecuteScalar(); : Throw Specified cast is not valid.
Posted by Russell Mangel at 4/21/2006 2:59:06 AM
When I run the following code on SQL Server2005 I get an exception every time. SqlInt32 maxct = (SqlInt32)sqlCommand.ExecuteScalar(); // Throws Specified cast is not valid. Why doesn't this work, or what do I not understand here? Since I could not make previous code work, I am forced to...more >>

pulling unique records from this query
Posted by musosdev at 4/21/2006 1:20:01 AM
Hi guys, need your help! (sorry this is quite long) I've got a table of Projects which I'm using with an asp:Repeater to display a list of the projects. Here's the sql... SELECT ProjectID, ProjectName, ProjectClient, DartsContact, LeadArtist, Projects.AreaOfWork, AreaOfDoncaster, StartDate...more >>

Data Parse Challenge
Posted by xxxdbaxxx NO[at]SPAM gmail.com at 4/21/2006 1:10:44 AM
Thanks in Advance, I would like to parse a column of ntext that looks something like this: 'I was born on Sept. 14, 1960. I graduated college on August 2, 1982, and went to France on Jul 17, 1985. I died on December 30, 2001.' I would like to break it into units that each end with the da...more >>

How to use EXEC
Posted by Mike_T at 4/21/2006 12:04:46 AM
Hi, How can I run EXEC conditionally? The EXEC syntax woks on its own but not when it's in a query. TIA Mike select 'name','surname', case when datediff (dd, getdate(), getdate()+2) between 0 and 2 then EXEC master..xp_sendmail 'mike', 'The master database is full.' else '' end as test ...more >>

OPENXML Insert into table failure not producing @@Error
Posted by Matt Jensen at 4/21/2006 12:00:00 AM
Howdy I've got the following example of a SP of mine (except in real life the @XML is ntext datatype) ----------------------------------------------------------- DECLARE @XML VARCHAR(4000) SET @XML = ' <?xml version="1.0"?> <roadrunner updatetime="2006-04-20T1752"> <rr_event> <webid>9...more >>

select all the rows where min_date_time <= curr_time <= max_time.(How?)
Posted by A.Neves at 4/21/2006 12:00:00 AM
Hi, I have a table with the DATETIME columns min_date_time and max_date_time, these columns store a min and max time for some date. Now I want to extract all the rows that limit curr_time (independently of the date). Something like this: ---------------------------------- SELECT * FROM M...more >>


DevelopmentNow Blog