all groups > sql server programming > march 2007 > threads for thursday march 29
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
Dynamically create table name in TSQL
Posted by bubbles at 3/29/2007 10:28:44 PM
Newbie using SQL Server 2005 Enterprise:
I need to dynamically create a TABLE NAME based on a variable
@PRODUCT,
but cannot seem to get it right. The table name has to be inserted
into the TSQL
statement location <Here_Is_My_Problem>
DECLARE @PRODUCT NVARCHAR(35)
DECLARE @NUM_ROWS I... more >>
Four table insert stored procedure SCOPE_IDENTITY
Posted by Sandy at 3/29/2007 6:54:02 PM
Can someone tell me what I am doing wrong in the following procedure? When
I try to execute it, I get an error saying @LoanID was not supplied.
Alter PROCEDURE InsertIntoFourTables
-- For tblLoans
@DateEntered datetime,
@DisasterNo varchar(20),
@DCMSNo varchar(20),
... more >>
Referring to comma separated values within a field
Posted by lesleyann76 NO[at]SPAM gmail.com at 3/29/2007 6:37:48 PM
In sql, in a given column I have records with information in them
which is separated by commas (ie, 1,2,5,8,12) or (KD, K, DF) etc., yet
it is all contained in one field. Well ordinarily when I evaluate the
contents of a field I am familiar with referring to the object.column
and generally look... more >>
Transaction issues
Posted by Ken at 3/29/2007 6:34:44 PM
I created stored proc which use transaction.
It worked fine for updating, inserting, deleting.
however, it didn't work correctly when I used for creating table.
Any idea????
this is the sample for that.
=================================
begin tran ken
save tran ken
Begin Try
execute... more >>
locking question
Posted by Roy Goldhammer at 3/29/2007 5:07:06 PM
Hello there
when i run Select statment on entire table. Does the table locked for other
uses even for select part of the table?
and when i run select statnent on part of the table. Does only that part is
locked even for select?
... more >>
Performance Difference using tinyint instead of bit
Posted by ataylor NO[at]SPAM regonline.com at 3/29/2007 5:01:42 PM
Hi-
We recently changed one table (200,000 records) to filter on a tinyint
instead of a bit. We're experiencing a lot of timeout problems, but
can't narrow down the cause. Does anyone have experience with a
performance hit from filtering on a tiny int field instead of a bit
field? Neither ... more >>
Question about temp tables
Posted by Roy Goldhammer at 3/29/2007 4:39:19 PM
Hello there
If i just set SELECT INTO #tmp or
CREATE TABLE #TMP INSERT #tmp
where does the temp table is being saved? in the memory or in the HD
... more >>
Basic DB Design Question
Posted by Ryan at 3/29/2007 3:42:49 PM
Double Column tables (ID and Field).. should they be used?
For example, lets say I have a Person table. Some attributes could be
Ethnicity, State, EyeColor, and HairColor. If I want the user to have the
ability to modify the available selections for those fields, the way I've
done it in the... more >>
Don't see what you're looking for? Search DevelopmentNow.com.
get DB access for an account?
Posted by Lynn at 3/29/2007 3:30:03 PM
Hi,
I would like to design a procedure to dropuser and droplogin in database for
terminated employee. Is there any exist script to use? Or How can I got the
Database Access for an account without go thorugh each user database?
Thank you for you help.
--
Best Regards,
Lynn... more >>
decrypt field
Posted by Tom at 3/29/2007 3:28:08 PM
I need to decrypt a field but it has a "salt" field attached to it, How can
decrypted either the field or the "salt" field in the db?
I'm running sql 05.
I have a decryptor tool that is decrypting other fields from my table fine,
but one as a salt field that i need to decrypt
... more >>
Inner Join ... maybe?
Posted by shapper at 3/29/2007 3:26:14 PM
Hello,
I have 4 tables as follows:
[Document] > DocumentId (PK)
[Comment] > CommentId (PK), DocumentId (FK)
[Rate] > RateId (PK), CommentId (PK)
[RateNames] > RateId (PK), RateName (NVARCHAR(200))
I need to get all RateIDs from Rate which are related to Comments that
are related to a giv... more >>
Trigger syntax question
Posted by Rhea at 3/29/2007 3:22:00 PM
I have this line in a trigger I am trying to create:
If (product.Gr_Bf_Each.value = 0) or (product.Gr_Bf_Each.IsNull)
begin
I get this error when I try to execute:
An expression of non-boolean type specified in a context where a condition
is expected, near 'begin'.
What is the probl... more >>
CLR Stored proc is timing out
Posted by Quimbly at 3/29/2007 2:44:01 PM
At one seemingly inoccuous step in my CLR stored procedure, execution stops
and the query times-out.
I've tried debugging the stored proc by stepping into it from within VS.
When I do, I get to the code in question, but then simply get this message:
WARNING: Debugger was accessing T-SQL ... more >>
Primary key
Posted by micatran NO[at]SPAM gmail.com at 3/29/2007 2:34:55 PM
Hi,
I am using sql server, and I want to add a primary key but I get this
error.
'1_REFAREA_ZIP_95' table
- Unable to create index 'PK_1_REFAREA_ZIP_95'.
ADO error: CREATE UNIQUE INDEX terminated because a duplicate key was
found for index ID 1. Most significant primary key is '37892'.
Co... more >>
Import of .csv not working
Posted by tshad at 3/29/2007 2:08:07 PM
I am trying import a csv into my system from EM but get the error:
ParseDisplayName Failed
The specified module could not be found
Why is that?
What I would like to do is just run a select on a .csv file.
Select * from c:\something.csv
Can I do this?
Thanks,
Tom
... more >>
fill <null> in outer join?
Posted by Mark B at 3/29/2007 1:59:58 PM
I have two tables link via a right outer join. In the results where
there is no record in the "B" table, it returns <null>. Is there a
way, via maybe a case statement, that I can put something into that
field?
Thanks,
Mark
... more >>
Delete row triggers drop table
Posted by scota NO[at]SPAM metrohealth.org at 3/29/2007 1:08:30 PM
I have a table called Calendar with a primary key on Cal_Num.
If I delete a row(s), I want a trigger that would delete a
corresponding table(s) within the database (i.e. delete Cal_Num=311
from Calendar and then tblEvents311 will be dropped).
If this can be done, how would I write the trigge... more >>
Trigger Question
Posted by Rhea at 3/29/2007 12:42:00 PM
I am new to SQL Server, using SQL Server 2005. I am a little confused about
when triggers fire. I am using Delphi ADO as the front end to the database.
I use batch updates to write master/detail inserts to the database. I need
to add a record to a table in the same database as well as a r... more >>
Combine records to calculate
Posted by David S. at 3/29/2007 12:17:32 PM
I have a table that contains arrival times for different vehicles. I would
like to be able to combine records by incident and calculate the difference
in time of thier arrival.
Example
incd vehi time
123 m03 12:04
123 e05 12:07
124 m02 14:09
124 e07 14:06
... more >>
stored procedure question
Posted by Tom at 3/29/2007 11:52:34 AM
I need to create a stored procedure thats take a parameter, then within that
stored procedure I need to run a select statement based on a different
parameter.
so I need to do something like this
select customersID from custTable where custname = @custname
then I need to take that cust... more >>
Sql Encryption -- entire db?
Posted by Dan English at 3/29/2007 11:45:33 AM
Are there any affordable tools out there to encrypt an entire sql database,
without requiring application changes? I need to encrypt data on a legacy
system (SQL 2000). NetLib would work, but its $10k per server.
Thanks.
... more >>
in cursor how to concatenate the result
Posted by shilkhanna NO[at]SPAM gmail.com at 3/29/2007 11:22:03 AM
here is my code, i need to get my result in concatenation format. Also
I need my output for a particular project_ID should show all the
employee working on that project_id. Right now i am getting the result
like this. thanks in adavance, any help will be appreciated.
Project_ID-150
Project_Na... more >>
COALESCEand Non Null Values
Posted by scott at 3/29/2007 11:19:14 AM
I use the below concatenation of the first, last name, middle initial and
suffix.using the COALESCE function. It works fine and renders the middle
initial and and a period if it the userMI field contains a letter or leaves
a space if the middle initial is null. The problem I've noticed is when... more >>
Error - Could not locate entry in sysdatabases for database ...
Posted by gv at 3/29/2007 11:09:51 AM
Hello all,
Using SQL 2000 sp4
I keep getting this error on this code:
Server: Msg 911, Level 16, State 1, Line 2
Could not locate entry in sysdatabases for database 'tot'. No entry found
with that name. Make sure that the name is entered correctly.
USE MASTER
IF NOT EXISTS(SELECT NAM... more >>
Insert Performance with CLR Table-Valued Function
Posted by jwilson128 at 3/29/2007 10:52:43 AM
I have developed complex logic in VB.NET that generates a set of 360
cash-flow records (18 fields) for each loan record and have
implemented this logic through the SQL Server 2005 CLR functionality.
I have reduced the time to read 10K loan records from the db and run
through the VB logic to cr... more >>
Sincronize values. Confusing
Posted by shapper at 3/29/2007 10:50:40 AM
Hello,
I have two tables as follows:
[Labels] > LabelId (PK), LabelName
[LabelsInPosts] > LabelId (PK), PostId (PK)
I am trying to do the following:
1. Two parameters are given:
- LabelsList (NVARCHAR)
> LabelsList has the format: Label1,Label2,Label3,Label4
- PostId (UNIQUEIDEN... more >>
DateTime Problem
Posted by Praveen at 3/29/2007 10:27:32 AM
We're having a problem with extracting date information from a MS SQL
DB. The 'earliestdispatch' column is defined as FLOAT size 53.
It has a value in the table as 39160
When I display it as: cast(earliestdispatch as datetime), it converts
it to 03/21/07
When I displayed it as DATEDIFF([MI]... more >>
Count Column in View
Posted by Don at 3/29/2007 10:14:01 AM
How do I write a view that counts the occurance of certain items in it.
Sample Table
1,Smith, 03/01/07
2,Grace, 03/02/07
3,Henry, 03/03/07
4,Smith, 03/04/07
5,Smith, 03/05/07
6,Grace, 03/06/07
The view would return
1,Smith, 03/01/07,1
2,Grace, 03/02/07,1
3,Henry, 03/03/07,1
4,Smith, ... more >>
SQL Memory Usage
Posted by tjsantabarbara at 3/29/2007 10:00:02 AM
Hello,
Until recently I had no idea what Sequel Server was. I still know very
little as to how it works and why. However, I do know that it uses a heck of
a lot of ram. After installing Office 2007 I noticed that when Outlook is
open the sqlser.exe as seen in the Task Manager hoovers at aro... more >>
Failover steps for Log shipping
Posted by Shahar Mesika at 3/29/2007 9:57:46 AM
Dear Team,
log shipping is enable on our db, created and restore transaction file
on Secondary server, all working good
how I can apply the transaction logs from the primary server on the
secondary server?
how I can switch the secondary db from read only to online production ?
Th... more >>
Find previous month's data
Posted by neheyen at 3/29/2007 9:28:06 AM
I have a need to find the data in the previous month. In other words, if ran
today, the where clause should include the date range of February 1, 2007 to
February 28, 2007. It should be automatic so that I can include it in a
scheduled DTS.
A previous dba left this snippet, but no one knows... more >>
How to get 4 max dates?
Posted by SQLFriend at 3/29/2007 8:44:07 AM
I would like to get the 4 max dates (largest) per customer, any idea how to
do it?
For exapmle:
Cust Invoice Date
1 1/1/06
1 2/1/06
1 3/1/06
1 4/1/06
1 ... more >>
Setting a field default questions
Posted by .Net Sports at 3/29/2007 8:36:59 AM
I need to assign a default for varchar datatype field in my dbase,
where as each time a row is added, an image name for that particular
field is automatically generated. What I need to do is to add the
'category' field name plus concatenate the ID # 'id', a primary key
integer datatype as the 'i... more >>
Is there an add-on for SSIS solution management?
Posted by erdos at 3/29/2007 7:23:32 AM
Solution/project management in SSIS (2005) is useless. No sorting,
categorization, view of multiple projects or organization of any
type. Is there anything available for SSIS solution/project
management that works similar to VS.NET's solution explorer?
... more >>
Difference between the two forms of query
Posted by Pradeep at 3/29/2007 6:30:01 AM
Hello,
I would appreciate if any one could help me in the following case.
The following query works fine but intermittently returns TimeOut expired
Error:
UPDATE TABTHREE
SET QTY =
(
SELECT SUM(QTY)
FROM TABONE
WHERE
TABONE.Col1 = TABTHREE.Col1 AND
TABONE.Col2 = TABTHREE.Co... more >>
"If" Condition
Posted by lesleyann76 NO[at]SPAM gmail.com at 3/29/2007 6:23:38 AM
In Sql, is there the equivalent of an "if" conditional statement? For
instance, in Access I might use IIf([ShippingStatus] = 9, [ShipDate],
"Delayed"). IIf(Condition, True, False).
... more >>
InStr - Similar Syntax in Stored Procedure
Posted by magix at 3/29/2007 2:53:56 AM
In Stored Procedure,
let say I have a Declare variable
FullName varchar(100)
How can I search in Stored Procedure , the Occurence of "John" in string
FullName at the very first position ?
Example in ASP:
InStr(1,FullName ,"John",1) =1
Thanks.
Regards,
Magix
... more >>
Stored Procedure
Posted by magix at 3/29/2007 2:38:22 AM
If I have following, but can I just SET the variable for string like : SET
@FullName = @vName1
It return syntax error. How can fix it ?
DECLARE
@vName1 varchar(100),
@vName2 varchar(100),
@FullName varchar(100),
SELECT Name2, Name2 FROM myRecord
OPEN dCursor
FETCH NEXT FROM dCurs... more >>
Declaring size when concatenating fields in a view
Posted by wawork NO[at]SPAM hotmail.com at 3/29/2007 12:07:16 AM
Beginer's question.
I have a view where I'm concatenating the lating names for genus and
species to create a virtual field named Scientific_Name. Because the
latin name is defined as 40 characters the resulting virtual field is
80. Is there a way to define the virtual filed to 50 for exampl... more >>
Configuring MSTSC
Posted by Mark Baldwin at 3/29/2007 12:00:00 AM
I am using .NET 2.0 with SQL2000. I have a simple test program for the
TransactionScope() object with encapsulates 2 calls using stored procedures
that are defined within a dataset. For example...
using (TransactionScope scope = new
TransactionScope(TransactionScopeOption.Required))
{
... more >>
How to use BCP utility with Functions having UNIQUEIDENTIFIER as input parameter
Posted by Swanand Mokashi at 3/29/2007 12:00:00 AM
Hi all --
I am running into trouble with the BCP utility getting data from a function
which has an UNIQUEIDENTIFIER as its input paramater
eg.
UDF is defined as :
CREATE FUNCTION dbo.GetElementsByUser (@UserGUID uniqueidentifier)
RETURNS @results TABLE (SiteGUID uniqueidentifier,
SiteNa... more >>
Characterset, accentuated characters and CSV file
Posted by Marc Robitaille at 3/29/2007 12:00:00 AM
Hello,
I need help with this.
This is an exemple of datas that I have to import.
ENL80051403;015678A5;O;"Société Sylvicole Chambord ltée";O;"Société
Sylvicole Chambord ltée";R;1143285790;O;2010-01-01
This is what I use to import de datas in the table
insert TDE001
select * from O... more >>
locking at the server
Posted by Roy Goldhammer at 3/29/2007 12:00:00 AM
Hello there
I have system that all the users are using it right now.
How can i know which tables are locked and which record in the table is
locked?
... more >>
Attach DB to remote server using SQL-DMO
Posted by Jozza at 3/29/2007 12:00:00 AM
Hi all,
Is it possible to attach a database that is currently on a local computer to
a remote server, so that a database would also be copied there?
TIA, Jozza
... more >>
SQL script to show dynamic header
Posted by Tony WONG at 3/29/2007 12:00:00 AM
In order to show dynamic header in the table result, i wish to replace
'February' by datename(month, @Date1) in line 3 & 4.
How can i do it? Thanks a lot.
******************* SQL script *********************
declare @Date1 varchar(8)
set @Date1 = cast(year(dateadd(m,-1,getdate())) as varc... more >>
|