markros, you are right. I am in your debt, I should have done a double check of the entire code before posting.
Thanks a lot for the lesson not only on what you have show me but also to review the code for what can be the obvious
markros, I also try the following code with a different error message:
CODE
USE RUMS
GO
UPDATE dbo.tbl_hits
SET ButtonText = substring(AppName,1, LEN(AppName)-8) ,
appName='DCR Tool'
FROM dbo.tbl_hits
WHERE (appName LIKE 'DCR%')
Results
Msg 207, Level 16, State 1, Line 0
Invalid...
Ok,markros, I did try it as follows:
CODE
USE RUMS
GO
--App DCR Tool (CHAR 8)-4
DECLARE @varlen int
SELECT @varlen = len(appName) from dbo.tbl_hits
@varLen=(@varLen-8)
UPDATE dbo.tbl_hits
SET ButtonText = substring(AppName,1, LEN(AppName)-8) ,
appName='DCR Tool'
FROM dbo.tbl_hits
WHERE...
markros thanks but, I need to extract the contents off the the column "appName" which contains a variable length string as long as (70 CHAR) and then take the results of the LEN and do a SET to the column "buttonText" for the string that is in the column "appName" less 8 characters, afterwards...
Thank you all, based on what hmckillop show me I have created the following code that is closer to what I am trying to accomplish;
CODE
--
USE RUMS
GO
--App DCR Tool (CHAR 8)-4
DECLARE @varlen int
SELECT @varlen = len(appName) from dbo.tbl_hits
@varLen=(@varLen-8)
UPDATE dbo.tbl_hits
set...
Thanks pwise and the same to you markros, but I still have a need to pass the results from a column to a variable, in that way I could manipulate the final out come such as:
@varLen=(column1 string length)
SET Colum2 = LEFT(column1,(@varLen -[a number])
---
I know this is feasible inside of...
Thanks pwise, I do not get an error but I DO NOT get a listing of all the columns only what appears to be the grand total of all rows:
Results
--
(No column name)
1 117910
--
Expect results
(No column name)
1 7
2 9
etc
--
I need to list and use the results from on each individual rows.
Any...
I get a different message, see below
--
Msg 512, Level 16, State 1, Line 2
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
(1 row(s) affected)
--
It should had displayed 19,972
I try the new code see below but I am still getting the same results:
--
USE AdventureWorks;
GO
DECLARE @EmpIDVar int;
SET @EmpIDVar = (SELECT LEN(FirstName)FROM Person.Contact)
SELECT @varLen
--FROM Person.Contact
GO
Results:
Msg 137, Level 15, State 2, Line 3
Must declare the scalar variable...
Thanks markros, I should add that I am using SQL Server 2005 here it is:
--
USE AdventureWorks;
GO
DECLARE @EmpIDVar int;
SET @EmpIDVar = LEN(FirstName)
SELECT @varLen
FROM Person.Contact
GO
Results:
Msg 137, Level 15, State 2, Line 3
Must declare the scalar variable "@varLen".
--
I have try...
Help to a begginer
I am trying to pass the results of a SELECT LEN to a variable and then display the results of the variable, but I must have the code wrong as an example:
USE AdventureWorks;
GO
DECLARE @varLen int
SET @varlen = SELECT LEN(FirstName)
SELECT @varLen
FROM Person.Contact
GO
Any...
To those that wonder why I can not use T-SQL, is because I have column with 70 Charcters that needs to be parse into other columns with diffent type of delimiters and not all in the same order. I there are samples out there than can do it using T-SQL, that will be great.
Here are 2 examples, I...
Thanks to all for the prompt response. I did a google search on the topic but what I got back is "how to call store procedure" but not how to write the procedure in C# or Visual Basic. I can not use T-Sql due to limitations and I am stuck with the database design. Agin any help is welcome.
NeilO
Can a store procedure be written in c# or Visual Basic using Visual Studio 2005 against a SQL Server 2005?
I need to do a column parsing into other columns within the same row, in a multirow table. I would like to know, if I can convert my code into store procedure. If its possible, are there...
I am trying to copy data from one table into another, the message that I receive is that is done. but data is not copied?? This is my proc:
---
USE RUMS
GO
---Drop procedure if it exist
IF (SELECT OBJECT_ID('dbo.hits_transfer','P')) IS NOT NULL - BEGIN
DROP PROC dbo.hits_transfer
END
GO...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.