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 > threads for wednesday march 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 31

DaysInMonth
Posted by Rahul at 3/21/2007 11:34:40 PM
Hi, how we can find out no of days in a particular month. I am using sql server 2000 Rahul ...more >>

DaysInMonth
Posted by Rahul at 3/21/2007 11:34:34 PM
Hi, how we can find out no of days in a particular month. I am using sql server 2000 Rahul ...more >>

Copying from one DB to another
Posted by Ant at 3/21/2007 10:33:03 PM
Hi, I'm trying to copy from one DB to another but I'm getting an error when doing so. The error I get is: The column prefix 'DB1.dbo.MenuView' does not match with a table name or alias name used in the query. This is the query: insert DB1.dbo.MenuView select * from DB2.dbo.MenuV...more >>

I need to hide datas on [database].MDF file on other MSSQL server. HELP!!!
Posted by Orgil at 3/21/2007 9:58:20 PM
Hi. I have a database named SUTDNet on a server on my computer. I created a few users for this database and i restricted any one's interests for this database. However, i can't hide my database's datas when anyone copies SUTDNet.mdf database file from my computer and attaches this file on other...more >>

SQL Server polling and MSMQ
Posted by z1hou1 NO[at]SPAM gmail.com at 3/21/2007 9:43:35 PM
Hi, I have a situation where I have to poll the SQL Server 2000 database for certain rows with a particular status. I would like to avoid polling, but for now it seems and easy way out. Would it be possible for a trigger on the table to post a message on a queue, in this case MSMQ and can T-S...more >>

SSIS null value handling
Posted by SqlBeginner at 3/21/2007 9:43:24 PM
Hi All, I have text files which has lots of records in it. Each column is seperated / delimited by pipe (|) sign. The problem i am facing is, after importing the textfile into sql server i find that all empty values are replaced by hyphen (-) within the DB. One way normally i will do is...more >>

equivalent of date() in sql statement
Posted by Bart at 3/21/2007 5:46:10 PM
Hi, i'm conerting a asp.net application from Access to Sql server express 2005. I have problem with cdate() and with date() within the sql string. My question is : how to translate this query for use with sql server? sql = "SELECT count(*)" _ & "FROM mytable " _ & ...more >>

trigger to determine if row is inserted or updated
Posted by Magnus at 3/21/2007 5:31:43 PM
Hello! I thought this was an easy one (and probably it is)!?!? I have a trigger that I want to do almost the same thing if a row is updated or inserted, but I can't figure out how to find out if a row is inserted or updated. How do I do that? Best regards /Magnus ...more >>



enumerate records
Posted by sali at 3/21/2007 5:29:39 PM
sql2000 is there some clever way to enumerate records in ordered query, so the enumeration reflects the order of records in query? one option is to use cursor to traverse the result set, but is too slow easy example could be, f.e.: set @recno_new = @recno_last +1 executed for each row...more >>

[odd] sniffing mssql;)
Posted by Areq at 3/21/2007 5:27:51 PM
Hi! I have on my PC about 30MB DB mssql. I want to upload this DB on some commercial server with mysql. This will not be a big deal until I can generate special sql query using PHP. The problem is, that the BD on the server need to have the same records as on my PC. I use special account pro...more >>

Optimizing Sub Queries
Posted by rh1200la NO[at]SPAM gmail.com at 3/21/2007 5:03:05 PM
Hey All. I have a stored procedure that, in the where clause has 4 subqueries. I just ran a sql trace on the db and it's usinq quite a bit of CPU (compared to the other queries). Aside from indexing, are there any other ways to optimize such a query? Thanks. ...more >>

BUG 2005 ?
Posted by Mario at 3/21/2007 4:33:47 PM
Hi ,=20 I need same help. I have this query.... declare @local_variable varchar (MAX) -- BAD !!!=20 Set @local_variable =3D '' Select @local_variable =3D @local_variable + V.type from master.dbo.spt_values V order by 1 select Len ( @local_variable ) -- Fine !! Set @local_vari...more >>

best way render date in MMDDYY format
Posted by Eric Bragas at 3/21/2007 4:31:22 PM
Hi People, What is the best way to render a date in MMDDYY format using T-SQL? I need to include a zero in MM if the month is 1-9. Thanks, Eric ...more >>

SQL query on multiple databases
Posted by Some1 at 3/21/2007 3:58:09 PM
Hello, I have two databases on one sql server. How can I run a single query on two databases? both databases have identical tables. servername: DB1 database1: operations01 database2: operations02 table: Usr_organizations I've put together a sql script to count channels from both databas...more >>

How to Count Averages? Newbie Needs Help
Posted by Chamark via SQLMonster.com at 3/21/2007 3:53:20 PM
Is there a way to count averages all in one Select statement? Obviously I am a newbie at this, so here is what I am attempting to do. My table is made up of 3 columns, StudentName, TestDate, Score. I want to average the students score between date 1 and date 2 and then count those averages tha...more >>

Setting transaction isolation level when reading from a view
Posted by Valerie Hough at 3/21/2007 3:52:53 PM
I would like to set Isolation Level to READ UNCOMMITTED for reading from a view. This is in an effort to prevent SQLError 1205, State 50. Can I use an SqlTransaction object as follows? (using C# - I have tested this code and it does not crash and it does return the correct result set) ...more >>

Stored procedure: exec with variable column name
Posted by nick at 3/21/2007 3:09:39 PM
Hi I came across this example that returns a result set with arbitrary start and end rows and was wondering if anyone could help me modify it so that it'll take an arbitrary column as for ordering. The SP was created fine but when I try to run it with say get_users 10, 20, 'username' it gives me...more >>

SQL Server Fill Factor question
Posted by ClinkeA at 3/21/2007 2:45:23 PM
Assuming my database contains two tables. Each table with one clustered index and no non-clustered indexes. Given that these tables may share a data page within an extent. Is there any benefit to using different fill factors for each of these tables when creating the table indexes? I und...more >>

Strange Error ?
Posted by Pat at 3/21/2007 1:34:52 PM
Hi Freinds, Trying to run this select a.memberid,a.adminactionmask,a.insertdate into #tmp2 from clsql5.db1.dbo.adminactionlog a where a.insertdate = (select max(b.insertdate) from clsql5.db1.dbo.adminactionlog b where a.memberid = b.memberid ) and a.adminactionmask & 4 = 4 and a.insertd...more >>

Server.MapPath in SSIS script task? name "Server" is not declared.
Posted by jobs at 3/21/2007 1:00:15 PM
I'm trying to read a file into a string.. this code has worked in vb.net/asp.net.. but won't an ssis script task. Imports system.io ... Dim FILENAME as String = Server.MapPath("chat.txt") Dim objStreamReader as StreamReader objStreamReader = File.OpenText(FILENAME) Dim contents as String = ...more >>

SQL SERVER 2005 BCP question
Posted by dwopffl NO[at]SPAM yahoo.com at 3/21/2007 12:33:15 PM
Stumped??? We are running SQL SERVER 2005, SP2. We are trying to bcp a small amount of rows (40,000) into our DB. When we run the bcp command by typing it directly into Server Studio, it run w/o an issue. Again, just 40, 000 rows. When we try to run it through our application (this is ...more >>

DTS package in SQL Server Management Studio
Posted by Noble Shore at 3/21/2007 12:28:57 PM
I am trying to use SQL Server Management Studio to create a DTS (.dtsx) package for a SQL Server 2005 database. Unfortunately, the program that uses it complains that there are insufficient rights to perform a "TRUNCATE TABLE" operation. One solution is to create the DTS package using the sy...more >>

possible to determine weekday with Tsql?
Posted by Rich at 3/21/2007 12:10:06 PM
Greetings, I need to pull some rows where the date column does not fall on a weekend. I was experimenting with the Day function, but that only give me the day of the month. How can filter out weekend dates? Thanks, Rich...more >>

Testing Enum values in Stored Procedures
Posted by rking(ISV) at 3/21/2007 11:57:05 AM
I'm writing several stored procedures that test the value of Integers which are represented by enumerated values in the VB application. My procedures are testing for 0,1,2 . . ., instead of new, scheduled, sent, cancelled, . . . I've considered using a user defined function such as uf_pmntS...more >>

DELETE records.
Posted by shapper at 3/21/2007 11:17:53 AM
Hello, I have 3 tables with their columns as follows: + LabelsInDocs [LabelId] PK FK , [DocsId] PK FK + Labels [LabelId] PK , [LabelName] + Docs [DocId] PK , [DocUrl] I set Cascade Delete On so when I delete a Doc all records in LabelsInDocs will be deleted. However, when a...more >>

ASP.NET 2 Data Binding with SQL 2005 XML
Posted by Greg Collins [Microsoft MVP] at 3/21/2007 11:15:59 AM
I am starting a project where I will be using the XML data type in SQL = Server 2005, and ASP.NET to display and update the content of the XML. I've been digging around for a bit trying to find some sources that will = explain the process of doing data binding in ASP.NET with the SQL XML, = bu...more >>

Simple Newbie Question (I hope) -- Subquery using 1 table
Posted by Tyrenta at 3/21/2007 10:53:08 AM
Hi all -- I've searched but can't seem to figure this out -- trying to write a query that returns an average of one column grouped by another set of criteria, as in: Table columns: item_id, rater_id, rating Output: item_id, rater_id, rating, average rating (all raters, per item) Can I do...more >>

How to select one of two columns?
Posted by Doug at 3/21/2007 10:21:07 AM
Question for the SQL gurus: I have a table that has two text columns, named ShortDesc and FullDesc. The users didn't start using the FullDesc field until a few years ago, it is blank in most of the records that are more than 3 years old. I want to write a query that returns the FullDesc column...more >>

monitor folder
Posted by farshad at 3/21/2007 10:06:18 AM
Hi, There is a folder on the network (FolderMain) that gets populated with .xml files. It is not known at what time of the day the folder gets populated with files. But it does happen every now and then. i.e. every few days or once a day, etc... What is the best way in .net 2.0 or sql serve...more >>

Page Life Expectancy
Posted by CLM at 3/21/2007 9:34:02 AM
I've got a 2000 server (SP4) with a Page Life Expectancy that often dips below 300. Is this truly a problem, i.e. does this mean I need more RAM? I guess what I'm asking is if there are "legitimate" reasons - admittedly I can't think of any - that would explain Page Life Expectancy < 300? ...more >>

pivoting one column
Posted by NH at 3/21/2007 9:24:33 AM
I am writing some dynamic sql and I need to 'pivot' a column of field names from the syscolumns table; I need to convert this: name FIELD1 FIELD2 FIELD3 FIELD4 To this: 'FIELD1,FIELD2,FIELD3,FIELD4' I can do it fairly easily with VBS but before I do, is there a simple way of d...more >>

Run a Stored Procedure for every row in a select?
Posted by jobs at 3/21/2007 9:13:46 AM
Do I need a cursor to do this? ...more >>

BULK INSERT, "String or binary data would be truncated."
Posted by brian.twardzik NO[at]SPAM usask.ca at 3/21/2007 8:09:43 AM
The Format File [_format.txt] 8.0 9 1 SQLCHAR 0 0 "|" 1 col1 "" 2 SQLCHAR 0 0 "|" 2 col2 "" 3 SQLINT 0 0 "|" 3 col3 "" 4 SQLCHAR 0 0 "|" 4 col4 "" 5 SQLCHAR 0 0 "|" 5 col5 "" 6 SQLCHAR 0 0 "|" 6 col6 "" 7 SQLCHAR 0 0 "|" 7 col7 "" 8 SQLCHAR 0 0 "|" 8 col8 "" 9 SQLCHAR 0 0 "|" 9 col9 "" ...more >>

SQL Server Error 1205, State 50 while reading a view
Posted by Valerie Hough at 3/21/2007 7:43:39 AM
Client is using SQL Server 2000 SP4. They are getting SQL Error 1205, State 50 while reading results from a view as follows: string connStr = "Server=MyServer;" + "IntegratedSecurity=SSPI;" "Pooling=true;" + "Initia...more >>

Min and second Min
Posted by schaapiee at 3/21/2007 7:35:22 AM
I want to grab the Min of a set of numbers, which works out fine. How can I grab the second lowest number? I tried to run another Min and exclude items from first Min, logically this would exclude the lowest and the second lowest would now be the first lowest, but it doesnt work. Does any...more >>

index
Posted by farshad at 3/21/2007 7:06:05 AM
Hi, There is a table which I regularly run a select query on. The select query always has a fixed where clause on only three of the columns with different parameters. This is a query that runs each time: select * from tblData where PersonNo = 2 and EmployeeType = 4 and DataDate = getdat...more >>

variable column count
Posted by NH at 3/21/2007 7:04:13 AM
I have a load of tables named RESULT1,RESULT2,RESULT3, etc. What I want to do is automatically load the contents of all of these tables into one large table. The problem is that the number of columns varies dramatically.. For example; RESULT1 may have 5 columns, RESULT2 may have 3 columns...more >>

Patindex and greed ..only want first
Posted by jobs at 3/21/2007 7:02:02 AM
hello. Say I have a string as follows "hello my name is bob #smith#_#jones#_goodbye' I only want to grab the first string #smith#. The below does not work. set @pattern = '%#%#%' select @s = PATINDEX (@pattern,@Parmin) Thanks for any help or information. ...more >>

how to select only the last x columns from a table
Posted by rsjrny at 3/21/2007 6:42:30 AM
Please bear with me I am just learning SQL I have a table that contains the following data, these are monthly useage counts Prod Oct2007 Nov2006 Dec2006 Jan2007 Feb2007 Mar2007 XXXXV031 52 9 18 8 18 102 XXXXV011 0 0 0 0 0 0 XXXXV040 ...more >>

Multiple results on one line
Posted by schaapiee at 3/21/2007 6:29:30 AM
I have a 'Number' which has multiple descriptions, and I want them to return on the same line in multiple columns instead of returning duplicate records. The info in all the other columns is identical. There is a number tied to the Desc items; so if you were to say Where Desc1 = 1 it would only ...more >>

Unable to create new view in database
Posted by Maurizio - Roma - Italy at 3/21/2007 4:02:03 AM
I receive this error when i try to create and save a new view on in one database of my server. The message is: "Impossible to resolve the expression for the tie or the associated object schema" I try to create the view with t-sql and also with SQL Management Studio. I access to the databa...more >>

Create key column value
Posted by Maurice at 3/21/2007 1:30:14 AM
Hi there, Hope that anyone can help me on this one. I want to create a key column which consists of the following: Year/Dept.nr/Incrementnumber By that I mean when I insert a record in the table I want de field Project_ID to be like this: 20070551 being the year 2007 dept.nr being 055 ...more >>

modified date-time
Posted by sali at 3/21/2007 12:00:00 AM
sql2000 entprs manager shows "created" date-time for stored procs. is there some way to have also shown "modified" date-time, as in win explorer for files? this could help me to separate procs that are modified inlast time. thnx ...more >>

how to view tables?
Posted by Areq at 3/21/2007 12:00:00 AM
Hi, How can I view tables I have im my DB? I have SQL server 2005 MSDE and I havent seen any component to view what's in my DB and to insert sql commands.... Regards, Areq ...more >>

Case insensitive for OpenXML
Posted by Frank Lee at 3/21/2007 12:00:00 AM
I found that OpenXML seems to be case sensitive, it means that it cannot find match columnname if case is different. Case-Sensitive is not good for me, I hope to set it up to case insensitive, is it possible? ---Frank Lee, using SQL2005 development sp1 ...more >>

Help needed on a Inner Query.
Posted by Manny123 at 3/21/2007 12:00:00 AM
Hi there, I would like to know how to accomplish the following; The Outer query is retrieving Sales numbers from a date range and the Inner Query should retrieve numbers from each date from the outer query od last year. @StartDate datetime, @EndDate datetime SELECT Sum(Sales) As Sale...more >>


DevelopmentNow Blog