all groups > sql server programming > june 2005 > threads for tuesday june 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
Can i join the same table with different aliases?
Posted by Soumya S at 6/21/2005 11:54:41 PM
Can i join the same table with different aliases?
Plz refer the below query....
SELECT
STVendorShipToCountry.StoreVersionId AS StoreVersionId,
STVendorShipToCountry.VendorId AS VendorId,
STVendorShipToCountry.CountryCode AS CountryCode,
PVendor.VendorName AS VendorName,
P1.LocaleValue AS Co... more >>
Type name is invalid for Stored Procedure
Posted by Chris Asaipillai at 6/21/2005 11:35:22 PM
I have a problem executing the following Stored Procedure from code.
The SP Text runs like this:
ALTER PROCEDURE prc_InsertContractDirectStatus_tmp
@var_ContractID VARCHAR(50)
insert into tblContractAuditHistory (ContractID)
VALUES (@var_ContractID)
The VB code which c... more >>
Function that check value of column
Posted by Ajay at 6/21/2005 10:11:02 PM
Hi,
I would like to create a generic user defined function as follows:
check_val(table_name varchar(100), col_name varchar(100), val varchar(100))
This function will then check the "val" in "col_name" column of "table_name"
table and returns 0 (not found) or 1 (found).
Since, dynamic S... more >>
CASE IN WHERE??
Posted by Child X at 6/21/2005 6:50:01 PM
Hi all,
I have the query below which works fine.
What i am after is making the WHERE condition:
'mine_id = @mine_id' conditional using a case statement
So far i have tried:
CASE @mine_id WHEN NOT NULL THEN accounts.mine_id = @mine_id
But have had no joy.
Thanks for any hel... more >>
Design issues with transactions...
Posted by Girish at 6/21/2005 5:18:22 PM
Starting new thread... (makes my q smaller!) :)
Example; I have the following transaction
BEGIN TRANSACTION --default trn isolation level here
SELECT SUM(points) FROM rActivitySectionToPerson WHERE personid = 6
WAITFOR DELAY '00:00:10'
INSERT INTO LineItem(personid, itemid, unitCost, quan... more >>
C2 auditing ?
Posted by Simo Sentissi at 6/21/2005 4:36:55 PM
Hello there
I just inherited a data farm and I noticed that the person before me had c2
auditing turned on.
I noticed that the trc files date only back to 04/05 and that the last time
a fiel has been modified is yesterday.
the rate of growing out of 200mb should make these files date of onc... more >>
remove file from tempdb
Posted by Britney at 6/21/2005 3:59:52 PM
hi guys,
I have a question.. I look at my tempdb database,
i have 3 data files along with 3 log files. when I look at the data files,
I have one master ( MDF ) and two NDF files.
I see this when I right-clicked on tempdb database on EM, select "property",
then I tried to delete one of NDF... more >>
XP error - SQL Server does not exist.
Posted by Richie at 6/21/2005 2:52:01 PM
Hi,
I have the following error on XP Pro machines (all updates) using Access to
run the following procedures: The aim of the routine is to access a table on
SQL 2000 lock it and increment the next number. The procedues runs fine on
Win2K machines but stops at about the 3969 mark in XP for... more >>
Don't see what you're looking for? Search DevelopmentNow.com.
base conversions function?
Posted by Keith G Hicks at 6/21/2005 2:34:31 PM
I've been through BOL and can't find this. Is there a built in function or
system SP for converting from one base to another? Or do I need to write my
own function for this? (specifically base 10 to base 2)
Thanks,
Keith
... more >>
extract data
Posted by jduran at 6/21/2005 2:21:03 PM
need code that would perform the same function as the MID() command in Access
used to do.
Data field called:
Title varchar 15
the data I want always starts with 'ABC-' and ends with '[ 1:1]' in
between are a mix of numeric/alpha characters that can be 7-9 digits or
characters lo... more >>
Service Pack Level
Posted by Mike Labosh at 6/21/2005 2:06:25 PM
I'm not a member of sysadmin so I can't look at the server properties in EM.
SELECT @@VERSION says this:
Microsoft SQL Server 2000 - 8.00.760 (Intel X86)
Dec 17 2002 14:22:05
Copyright (c) 1988-2003 Microsoft Corporation
Standard Edition on Windows NT 5.0 (Build 2195: Service Pack 4)
... more >>
northwinds db download?
Posted by Kurt Schroeder at 6/21/2005 1:47:03 PM
does anyone have a link to where i can get the northwinds database? I need it
for sqlserver2005. Thank's
kes... more >>
Visual Studio
Posted by access2sql at 6/21/2005 1:44:02 PM
Hi-
I have installed SQL Server 2000 and was wondering if Visual Studio is my
ticket to developing a database app with SQL Server. From what I've been
finding and reading on the net, it appears that VS is good for someone not
familiar with SQL.
I would like to steer clear of developing wit... more >>
Rowset does not support fetching backward.
Posted by SMV at 6/21/2005 1:03:05 PM
Hi All,
I am using SQL 2000/ Visual InterDev 6.0. I am getting the above
error when I use Rs.MovePrevious, Rs.MoveFirst in the following Code.
SQL = "SELECT * FROM tbl ORDER BY LastName,FirstName ASC"
Set Rs = Server.CreateObject("ADODB.Recordset")
... more >>
How do I export each table's data into its own text file
Posted by JohnnyMagz at 6/21/2005 12:15:03 PM
OK, so I just learned how to use the bcp command line utility to export the
contents of a table to a text file. I'd like to create a script that loops
through each of my talbes and exports its data into a text file with the same
name. What is the best avenue to to this using SQL Server 2000?
... more >>
To normalize or not to normalize
Posted by Sandy at 6/21/2005 11:38:11 AM
Hello -
I have a table that current has fname, lname, address, city, state, zip and
I don't expect it to ever get any larger than 700,000 rows. It will be
accessed as a directory. I then thought I should include country which may
produce another 700,000 tops to bring it up to less than 1.... more >>
SQL7.0
Posted by Gérard Leclercq at 6/21/2005 11:16:54 AM
Hi,
for the moment i use asp classic with Access 2003. My provider ask me to
upgrade to MS Sql.
Are there tools in Sql7.0 to import the Access db ?
My provider speaks of opening for me a Sql Db on the server. Can i, just
like i do with the Access, down- an uploading a Sql db ?
Gérard... more >>
adding login aliases
Posted by Bill Orova at 6/21/2005 11:13:34 AM
Hello all,
I have a small situation here We have a well entrenched method of
aliasing logins to add users. We use sp_addalias in the format of exec
sp_addalias 'xxx','dbo'.
My question is for this alias how do you add permissions for certain
databases or to access the design venue of an exi... more >>
performance question
Posted by simon at 6/21/2005 10:35:30 AM
I have one performance question:
IF I write sql like this:
declare @variable bit
set @variable=0
.......from table1 INNER JOIN table2 ON 1=@variable
then execution time is 500 milisecond
If I write like this:
.......from table1 INNER JOIN table 2 ON 1=0
then execution time is 2... more >>
Querying a range of addresses
Posted by Jenny at 6/21/2005 10:25:05 AM
I have a table w/ ID number and address number. I am trying to query a
specific address to see if it is in a range. Here is the example table:
ID Add_Num Street
23 1600 Westwood
24 1800 Westwood
I will know the ID number when I query. So say I want to know if 1653 is in
the range ... wh... more >>
SEM auto-generated SQL produces error
Posted by John Grandy at 6/21/2005 9:57:29 AM
The following is part of the SQL auto-generated by SEM for a creating a
database :
IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name =
N'Database1')
DROP DATABASE [Database1]
GO
If I delete Database1, and then run the database-creation script, I receive
the error:
Serv... more >>
xp_cmdshell 'dtsrun...' and xp_cmdshell 'bcp...' fom trigger keeps blocking
Posted by kcwms at 6/21/2005 9:42:07 AM
THE ENVIRONMENT.................................
My dev machine: WINXP PRO, SQL SERVER 2K SP3, Sql Server User
global_catalog_prod is dbo to its database
The prod machine: WIN SERVER 2003, SQL SERVER 2K SP1, Sql Server User
global_catalog_prod is dbo to its database
In both instances I gave t... more >>
day list with commas and hyphens problem
Posted by Keith G Hicks at 6/21/2005 9:39:56 AM
I have some events that can occur on any given day(s) of the week. The user
can choose any or all days via checkboxes. In a report, I need to return the
days that were chosen. But I need to do it like this:
If the user chooses 2 days next to each other such as Thu, Fri:
"Thursday, Friday"
... more >>
Error Ignoring
Posted by NT at 6/21/2005 9:28:04 AM
Hello,
Is there anyway to ignore error in function or stored procedure while
calling function for multiple orders.
--
- NT... more >>
Backup help
Posted by Ed at 6/21/2005 9:16:12 AM
Hi,
I am going to create a secondary file .ndf and place the
"AccountReceivable" table into that secondary file. My question is when I do
the backup "Full/Transaction/Filegroup" backup, how does it work.
1. Does the Full Backup/Differentail Backup still cover all Primary and
Secondary Fi... more >>
problem debugging stored proc - datetime param problem
Posted by Rich at 6/21/2005 8:55:03 AM
when I try to debug my sp which takes 2 datetime params I get the following
message after I try to execute the debugger
[Microsoft][ODBC SQL Server Driver]Invalid character value for cast
specification
When I click on debug I enter 5/1/2005 for @start and 5/31/2005 for @end
I also tried... more >>
permissions required for TRUNCATE
Posted by Tarren at 6/21/2005 8:50:53 AM
Hi:
I am running into trouble where my stored procedure includes a statement to
truncate one of my user tables.
The stored procedure fails unless the user running it has DBO permissions on
the database.
What is the statement to grant TRUNCATE on a table to a user without having
to ope... more >>
Assigning a value to a variable ?
Posted by Chubbly Geezer at 6/21/2005 8:18:03 AM
I'm sure this is a very easy question to answer but here goes anyway.
I am trying to assign a value to a variable with a select statement based on
a table name variable. i.e.
SET @SqlString = N'SELECT @TotDue = SUM([Due to pay]) FROM ' +
@NewRenewalAnalysisbyRenType
PRINT @SqlString
EXE... more >>
SQL Best Practice
Posted by Concatto at 6/21/2005 8:13:03 AM
Hello,
I'm trying to write a SQL stored procedure to add/change a record in a
unique-keyed table and wanted to know best SQL practice approach.
I'm currently using IBM's legacy language RPG-ILE (a procedural language)
for all database programming, and the steps for adding a record usually ... more >>
Granting permission
Posted by JMNUSS at 6/21/2005 7:20:03 AM
I am trying to fix a permission issue, we have a user who connects to a DB
through an AD group. when she tries to create a proc she gets an error
stating that...
Server: Msg 3704, Level 16, State 1, Line 3
User does not have permission to perform this operation on procedure
'dbo.Rptblah'.
... more >>
List of Logged ON USERS mk2 (problem)
Posted by Steve'o at 6/21/2005 7:01:05 AM
Hi, I have a very similar request to a previous post, but did not want to
hijack that one as I already use a particular method but seem to have made an
error as it doesn't work.
Seeing the other post, I like the sp_who2 modification idea, so may just run
with that, but if anyone could look ... more >>
Writeback problems using normalized databases
Posted by PhiberOptic at 6/21/2005 6:34:02 AM
Hi,
I'm using a highly normalized Database on SQL Server 2000 to represent
entrys from many tables together in one Office WebComponent.
The Problem is, changing and writing data back to the database is not
possible, as I'm working on data from many different tables represented by a
view wi... more >>
Question with DBCC SHOWCONTIG output
Posted by KCSL at 6/21/2005 2:58:02 AM
I'm confused with the foloowing output (see below)
According to "Inside SQL Server 2000", a high value in Scan Density is good,
and a low value in Extent Scan Fragmentation is also good.
However, I have a high value in Scan Density and also a high value in
Extent Scan Fragmentation. To make... more >>
calculating employee commission
Posted by ngorbunov NO[at]SPAM onetouchdirect-dot-com.no-spam.invalid at 6/21/2005 1:00:09 AM
I have the following tables
Table1
Emp %Sale
1 2.
Table2
Project %Sales CommissionAm
A 2.2 1.5
A 2.4 1.7
Employee1 has 2.3 % sales.
I have to figure out from Table 2 which commission amount to apply
Because emp1 has 2.3 I need to apply $1.50
How... more >>
Transpose Query Row to Columns
Posted by Tim M at 6/21/2005 12:58:06 AM
Hi,
I have a query in a stored procedure that always returns a single record.
There are about 15 columns returned also.
For reporting purposes I'd like to transform the output into a recordset
consisting of only 2 columns. The first being the original column name and
the second being t... more >>
SQL Server 2005 CTP installation
Posted by John at 6/21/2005 12:10:40 AM
Hi all,
I've just installed SQL Server 2005 CTP but have no idea of where to go to
view objects like I can in Enterprise Manager.
I have read about Management Studio but can't seem to find any program group
for it.
Am I missing something? How can I create tables/views/triggers and the lik... more >>
What is the best maintenance plan
Posted by Kjell Arne Johansen at 6/21/2005 12:04:02 AM
Hi
I did not get any response in tools so i try this group.
I'm going to specify a database maintenance plan in SQL Server Enterprise
Manager, but I do not know what the best maintenance choices are.
The database that shall be maintained is an alarms and events database in a
process con... more >>
Select Case in SQL Server
Posted by Kiran at 6/21/2005 12:00:00 AM
Hi,
Is there something similar to Select case(VB.Net) in SQL Server
If yes, can someone provide the syntax please
else alternate ways of doing this
Thanks
Kiran... more >>
INSERT INTO #temp EXEC (@sql) question
Posted by Michael Sander at 6/21/2005 12:00:00 AM
Hi ng,
is there anyway to use the statement
INSERT INTO #temp EXEC (@sql) question
without creating the temporary table in advance?
The number of columns selected in @sql may change, so im looking for
something like
SELECT * INTO #temp FROM ...
thx,
Michael Sander
... more >>
IP Address
Posted by BlackMan at 6/21/2005 12:00:00 AM
How can I determine IP address of the user connected to my MSSQL2000 through
Win application....
10x
... more >>
Timeconsuming mass update.
Posted by Geir Holme at 6/21/2005 12:00:00 AM
Hi all.
The following query takes a long time to run. Is there any faster ways to
fill inn this value into a newly created field.
UPDATE Table1 SET Table1.Field1 = Table2.Field2
FROM Table1
INNER JOIN Table2 ON Table2.ID2 = Table1.ID2
There are some indexes on Table1 and about 4... more >>
List of Logged ON USERS
Posted by Prabhat at 6/21/2005 12:00:00 AM
Hi All,
I use SQL Server 2000. Before I do some critical DB Updates I wanted to know
the LIST of Users logged on to the SAME DB, so that I can Inform them to
Logout from the DB before I start the Process.
How Do I know the List of Users that have logged on to the DB - The List
should not in... more >>
Complex WHERE command...
Posted by Scooby at 6/21/2005 12:00:00 AM
Well, "Complex" is a bit of a misnomer here, but this is the idea...
If I want to select based on an element having multiple values, how can I
combine this simply in the WHERE clause?
The harder way is:
SELECT * FROM MYTABLE WHERE ELEMENT = 'A' OR ELEMENT = 'B' OR ELEMENT = 'C'
OR ELEMENT =... more >>
varchar to int
Posted by Allan Nielsen at 6/21/2005 12:00:00 AM
Hello
In a table called data, I have columns dataID and value.
value datatype is defined as varchar with length 20. How do I (with a
"select") return the value field as a float instead of varchar? I'm
guessing I need either cast or convert, but I cannot seem to make it work
properly. A simpl... more >>
Audit trail for web application using SQL server.
Posted by Parag at 6/21/2005 12:00:00 AM
Hello,
I have been assigned the task to design the audit trail for the ASP.NET web
application. I don't know what the best practices for such audit trails are.
Our application one dedicated user name and password to perform the database
operations. I need to capture all the operations which are ... more >>
Please give me sample coding for "exporting table to excel file".
Posted by SOHO at 6/21/2005 12:00:00 AM
SP question
Posted by ichor at 6/21/2005 12:00:00 AM
hi i had read somewhere that if i want to find out if a record exists i
shoudl avoid using this syntax (@@rowcount)
but i cant remember why?
select * from cost
if @@rowcount = 0
begin
print 'doesnt exist'
end
... more >>
sql
Posted by ichor at 6/21/2005 12:00:00 AM
hi how can i make this piece of code shorter?
thanks
if exists(select * from cost_revenue where cost_revenue_id = 80)
begin
print 'yes'
select * from cost_revenue where cost_revenue_id = 80
end
else
begin
print 'no'
select * from cost_revenue where cost_revenue_id = 55
end
dont... more >>
DataGrid printing
Posted by Junior at 6/21/2005 12:00:00 AM
Hi,
I have DataGrid in VB.Net loaded with SQL table and I need to print that
out.
Can someone please help me
... more >>
|