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 > june 2007 > threads for thursday june 14

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

Dynamic Date Search without writing dynamic SQL: Quick Tip!
Posted by Namwar Rizvi at 6/14/2007 9:19:32 PM
Many of us sometimes got stuck when our application requires flexible search mechanism where one or all of the search parameters can be NULL. These type of queries requires you to implement a mechanism which takes care of all possible combinations of input to the stored procedure. Following...more >>


How to loop a temp table?
Posted by Daniel Badger at 6/14/2007 5:34:00 PM
I have a statement in my stored procedure that has the following as an example - INSERT #TempTableOutput EXEC (@select + @from + @where + @order) How could I then loop through the records of #TempTableOutput to update some blank fields that were created in the intial select statement?...more >>

Disable Index in mass insert, update & delete
Posted by bzh_29 at 6/14/2007 3:45:28 PM
Hi, One of my apps synchronise two databases. In some case, the number of elements could be important ( > 10 000) for my area ... Elements are insert, update or delete depending on what happened on the first database ... In order to accelerate SELECT on some tables, indexes has been created...more >>

synonym for StProc prevents ADO.Parameters to Refresh()
Posted by keyser soze at 6/14/2007 2:00:50 PM
hi i have a stored proc, pointed by a synonym i wish to execute it vía: cmd.commandType= adStoredProc cmd.commandText= "s_MyStoredProc" cmd.parameters.refresh ---> to get the collection the last line, can't retrieve the Parameters[] collection if i execute the stored proc directly the ...more >>

Modify identity field? Can it be done?
Posted by Rob at 6/14/2007 1:45:06 PM
I have a table with an identity field (RecordNumber, int), among other fields. Our vendor would like us to produce a tilde(~) delimited file of this table. They'd like us to present the values in the identity field as a 15 digit long value with preceding zeros. For instance, an identity val...more >>

Update help
Posted by vovan at 6/14/2007 1:21:54 PM
I have Table with Primary and Foreign key fields of varchar type. Foreign key field references to the same table. Table contains Financial Accounts data. Accounts can be independent and can be like children of another account. So, if for instance Foreign key field contains NULL then this acc...more >>

count number of duplicates in a table
Posted by jobs at 6/14/2007 1:19:50 PM
This list all rows with a one or more dup. select BillNumber from pineiro_lec_new group by BillNumber having count(*)>1 How can I return the total number of rows with dups? ...more >>

Number Rows based on an ID
Posted by dwopffl NO[at]SPAM yahoo.com at 6/14/2007 12:51:01 PM
I need to take the data from the following table and populate a new table with row number colmun based on an objid EXAMPLE I have the following table OBJID FinClass RcvDate TransID AMT 1 1 01/01/1990 34 17.00 1 ...more >>



CLR Stored Procedure gives "Failed to grant permission to execute"
Posted by JohnD at 6/14/2007 12:41:03 PM
Hello All, I'm new to all SQL so please forgive me if I've missed something obvious. With SQL 2005. I have a C# stored procedure which works fine. I then modified the C# code to call into an unmanaged (C++) DLL. I've set this up to use PInvoke to get into the unmanaged DLL (which is ca...more >>

getting all the records
Posted by rodchar at 6/14/2007 11:12:00 AM
hey all, i'm going over a Data Tutorial that showed the following statement: SELECT ProductName, UnitPrice FROM Products WHERE UnitPrice <= @MaximumPrice OR @MaximumPrice = -1.0 According to the documentation if @MaximumPrice = -1.0 then all records will be returned. Huh? How does tha...more >>

Preface column names with table tames?
Posted by Ronald S. Cook at 6/14/2007 11:06:19 AM
Is there a compelling reason to preface column names with table names? E.g. Author -------- AuthorID AuthorName Instead of... Author ------- ID Name I was agreeing with the prefacing this morning because it would distinguish each column clearly when doing a SELECT * when join ta...more >>

French, German, Italian SQL Queries
Posted by UW at 6/14/2007 11:03:01 AM
Thank you for quick response on my original posting and I have different question. How do you write SQL queries in French, Gemran and Italian? Do you use command or period for decimals? Do you say: INSERT INTO SomeTable (DoubleColumn1, StringColumn2) VALUES (123...more >>

How best handle redundant column names from being returned?
Posted by Ronald S. Cook at 6/14/2007 10:54:05 AM
I have been talked into (convinced) to preface all column names with the table name: Author ------ AuthorID AuthorName Book ---- BookID BookTitle AuthorID (assume only one author per book for this example, please) The reason is valid and I agree with it (although it doesn mean mo...more >>

Authentication challenge
Posted by Jim at 6/14/2007 10:50:06 AM
Hello, I have been asked to log the "computer" startup and shutdown time to a SQL server database. I have created a Kixtart computer shutdown script that, during computer shutdown, writes an entry to a text log file on a server share as well as to a SQL server database. As this event is a ...more >>

backup help
Posted by iiman at 6/14/2007 10:04:50 AM
When I do a full backup on a database, i guess this error Msg 9987, Level 16, State 1, Line 1 The backup of full-text catalog 'PhraseologyIndex' is not permitted because it is not online. Check errorlog file for the reason that full-text catalog became offline and bring it online. Or BACKUP ...more >>

European query?
Posted by UW at 6/14/2007 9:53:01 AM
I am new to internalization and I have ran into a problem recently. I have a SQL query generator which does something like: 1. Read double value from textbox 2. Convert it to double for some calculations. 3. Convert it back to string from double. 2. Attache the value to...more >>

Setting Parameters for Non-Existent Rows???
Posted by Don Miller at 6/14/2007 9:38:38 AM
In an SP I have a SELECT that returns only one row and one column (if it exists) and places the result in a parameter that I use later in calculations like, SELECT @int = ISNULL(IntegerValue,0) FROM TableName WHERE FirstColumn = 'One' AND OtherColumn = 'Red' AND UniqueID = '123...more >>

create namespace question
Posted by Yankee Imperialist Dog at 6/14/2007 9:26:00 AM
I use a data layer for almost all my db calls I use a business layer for almost all my generally needed rules both are in a series of classes, loginfunctions for user authentication and authorization settings, chartfunctions for rules concernng global stuff, datafunctions, and ... I've read...more >>

Temp Table Question
Posted by Jack at 6/14/2007 8:55:34 AM
Hello I have a programmer who wants to retrieve a list of items from three different tables, returning them in one result set. The problem is the sort orders are going to be different for each query. The row counts returned are very small, but this will be used on a high volume web site. ...more >>

query for table names
Posted by Jerry J at 6/14/2007 8:35:22 AM
I have a database with hundreds of tables. Sometime I want to find tables with particular text in the name. Is there a way for me to use system tables to search for text in a table name. The query would be something like "Select * from TableNames where tableName like '%DEF%' Thank yo...more >>

select top 3 rows from each group?
Posted by Rich at 6/14/2007 8:31:00 AM
I need to select the last 3 rows for each code group - by date. I am thinking some along the lines of select top 3 * from #tmp1 where code = 'a' order by vDate desc But this will return only the rows for code 'a'. How do I retrieve the rows for codes 'b' and 'c'? I am thinking something...more >>

Indexed VIEWS - View has WHERE CLAUSE
Posted by RHarrison at 6/14/2007 8:25:00 AM
Hi, Has anyone encountered the following error when trying to create and indexed view. Create failed for Index 'IDX_RHFROMPAUD'. (Microsoft.SqlServer.Express.Smo) Cannot create index on view 'MYRIAD2.dbo.RHISTORY_FROM_PAUD' because column 'Quantity' that is referenced by the view in th...more >>

Putting carriage return/linefeeds into fields
Posted by BobRoyAce at 6/14/2007 8:13:28 AM
Let's say that I have a table, Table1, which has two fields: Field1, Field2. I want to write a query that will return those two field values in one field with a carriage return/linefeed between them. For example, using VB syntax: SELECT Field1 + vbCrLf + Field2 FROM Table1 How could I acco...more >>

Ignore rollback and drop database
Posted by Damien at 6/14/2007 7:23:08 AM
Thankfully, this is in a test environment, and is not causing me a live issue, but it got me thinking: I've got one database on my server that I noticed was in the middle of a large transaction that it had been working inside for several hours. At this point, I knew that the output from the tr...more >>

quoted binary
Posted by sbruno92 at 6/14/2007 6:52:01 AM
Hello, In sql_server 2005, I would like to convert a binary in string and vice-versa like this 73C5E(binary) -> '73C5E' nchar(5) and '73C5E' nchar(5) -> '73C5E'. I have to make multiple comparisons between binaries and strings and I must use ansii strings somewhere else. is anyone can ...more >>

Big INT as Primary Key
Posted by S Chapman at 6/14/2007 4:33:25 AM
I have a table that potentially can hold billions of rows and hence I was wondering if I can use a BIG INT instead of INT as the primary key. Are there any adverse effects on SELECT statements (performance) becuase of the larger size (8bytes) of the BIG INT? Thanks in advance. ...more >>

Auto-increment column ???
Posted by calderara at 6/14/2007 4:12:01 AM
Dear all, I need to define an auto-increment column which will be used as a primary key . If I defined that column field as INT and then configurred the Seed value to 100. What will happen if the auto increment field goes over the INT type ? how can it be reaaly uinique with the time ? ...more >>

update inner join
Posted by farshad at 6/14/2007 4:10:00 AM
Hi, As you can see the following two tables have different data. So the IDs will vary. Can you let me know the sql query to update table1 Thanks ----------------- Table1 IndexID Name ParentIndexID 1 BR DATED NULL 2 BR IPE NULL 3 BR NYMEX NULL 4 DUBAI NULL 5 F10MEDCC NULL 6 F10MEDFC...more >>

Urgent........rollback updated query
Posted by Manju at 6/14/2007 3:11:10 AM
Hi All, please let me know if there is any way i can rollback the update query? i am using sql server and my auto commit option is on......... please help... ...more >>

How to backup a very large database
Posted by AliRezaGoogle at 6/14/2007 3:03:54 AM
Dear Members Hi, I am a little confused about making backup of a very large database. let me explaine Suppose that we have a very large database. In our database there is a bulky table called "TTable". It is placed in a filegroup. Every day new bulk data is added to TTable. Remaining tables in...more >>

PIPE (Vertical bar) as fieldseparator using BCP.(xp_cmdshell)
Posted by geir at 6/14/2007 1:52:01 AM
Hi all. A new litle chalenge. I cant seem to get the pipe sign as fieldseparator (|). Gets the following error using -t| -t\| *** '-CDanish_Norwegian_CS_AS' is not recognized as an internal or external command, operable program or batch file. **** -- Thanks all Regards Geir...more >>

trigger for more than one table
Posted by Ant at 6/14/2007 1:01:00 AM
Hi, I have multiple tables that have an Insert applied to them when a Record is saved. I can't get into the front end so I must use a trigger to prevent a record from being entered under certain circumstances. If tbl1 is the main table, & tbl2 is the detail table, & I want to roll back t...more >>

Grouping with a twist
Posted by M A Srinivas at 6/14/2007 12:30:38 AM
/* Grouping Values Need to group amount on following logic 1. Grouping should be based on +0.02 or - 0.02 2. If a value is selected into a group , it should not be considered in any other group In the example below 10.04 is within .02(-) of 10.02 and also with in 0.02 (+)...more >>

Getting out fieldnames using BCP to export data to txt files
Posted by geir at 6/14/2007 12:03:00 AM
Hi all. I am using this comand to export to a .txt file (to avoid usin SSIS). How do I get the fieldnames in the .txt file. I just get the data itself. Any ideas? EXEC master..xp_cmdshell 'BCP multicase..vekRptItegraFilExport out K:\MultiCase\Filexport\SQL2005Eksport\ProduktFile.txt -c ...more >>


DevelopmentNow Blog