HelloI have having trouble displaying some simple columns in ascending order.I know that the database is populated and I can get the more complex code to work if I display like this: SELECT FName, LName, Town, '<a href="' + url + '">' + Site + '</a>' as LinkFROM Names_DBWHERE FName = 'Tom' And url like 'http:%'ORDER BY LName ASCBut I need a simpler view but I can't get it to workI have tried this:SELECT FName, LNameFROM Names_DBORDER BY LName ASCAnd thisSELECT FName, LNameFROM Names_DBORDER BY LName ASC; And This:SELECT FName, LNameFROM Names_DBORDER BY LName 'ASC' What is wrong with this syntax?ThanksLynn
I have a query and I need to check to see if a field is occupied, i.e., it can have anything in it, i just want to see if something is there... this is what I want, but of course, anything isn't the right word here...
This is a Stored proc I am working on I dont know much about stored procs. This is what I am trying to achieve The proc takes two input parameter and returns one outparameter.
This is what I have
SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO
CREATE PROCEDURE [dbo].[GetNextAction]
( @Code char(10), @Track varchar(30), @NextAction ntext output ) AS BEGIN
SET NOCOUNT ON; Declare @ID int; @ID = Select Sequence from [dbo].[Track] where Code=@Code; Declare @nextCode varchar; @nextCode= Select Code from [dbo].[Track] where sequence =(@ID+1); @NextAction= Select nextAction from [dbo].[CaseStage] where Code=@nextCode; return @NextAction;
END GO
I guess you can understand what I am trying in the proc but the rules and syntax are wrong. Please help me with this. Thanks
If someone can show me the correct syntax for the right side of the code below, I'd appreciate it. srcMoreInfo.InsertParameters("Address").DefaultValue = DirectCast(cuwMoreInfo.FindControl("txtAddress"), TextBox).Text
WHATS WRONG IN THIS CODE ? --------------------------------- PS: I'm getting this error: -------------------------------
Server: Msg 214, Level 16, State 2, Procedure sp_executesql, Line 7 Cannot convert parameter '@statement' to ntext/nchar/nvarchar data type expected by procedure.
Hi, I'm new to SQL and was wondering if there was an easier way to filter data.
I have two tables -
The first table called Names of Companies has a column named: NAMES
NAMES XYZ Company ABC Limited Liability Company ZZZ Corporation KKK Inc. ABC Inc.
The second table called Keywords has a column named: WORDS
WORDS Company Limited
I want to search for all NAMES that contain the WORDS in some form
The results should be:
NAMES XYZ Company ABC Limited Liability Company
Technically, I can get the results I want by manually typing into the SQL statement all the words that appear in the WORDS column.
SELECT * FROM [Names of Companies] WHERE [Names of Companies].Names Like "*Company*" Or ([Names of Companies].Names) Like "*limited*"));
But is there a way that I reference the table Keyword instead of typing into the query statement all the words that appear in the column WORD? I have a lot of words to search for.
I'm trying to create a SQL job in SQL Server and am a little unclear about the formatting.Here's a snippet from the stored procedure that creates the job:CREATE PROCEDURE [dbo].[spArchive] @DB varchar(30), @Date DateTimeAS EXEC msdb.dbo.sp_add_jobstep @job_name = 'ArchiveIncentives' , @step_id = 1 , @step_name = 'ArchiveAHD' , @subsystem = 'TSQL' , @command = 'spArchiveAHD ''@Date''' , @on_success_action = 3 , @on_fail_action = 2 , @database_name = '@DB' , @retry_attempts = 1 In this case, the job will be calling this stored procedure:CREATE PROCEDURE [dbo].[spArchiveAHD] ( @dtArchiveBefore DateTime)AS I'm unclear about these lines: @command = 'spArchiveAHD ''@Date''' @database_name = '@DB' Do they look correct to you or should I drop some/all of the apostrophes?Robert W.
I try to call the storeproc to perform task by allowing only input 6 of length. The syntax over here might not be relevant, im seeking for correct syntax. webform Dim connString2 As String = _ConfigurationManager.ConnectionStrings("Local_LAConnectionString1").ConnectionString Using myConnection2 As New SqlConnection(connString2) Dim test01 As IntegerDim myPuzzleCmd2 As New SqlCommand("GetRandomCode", myConnection2) myPuzzleCmd2.CommandType = CommandType.StoredProcedure Dim retLengthParam As New SqlParameter("@Length", SqlDbType.TinyInt, , 6) < -------- allow 6 letters in length to be input retLengthParam.Direction = ParameterDirection.InputmyPuzzleCmd2.Parameters.Add(retLengthParam) Dim retRandomCode As New SqlParameter("@RandomCode", SqlDbType.VarChar, 30) retRandomCode.Direction = ParameterDirection.Output myPuzzleCmd2.Parameters.Add(retRandomCode) TryDim reader2 As SqlDataReader = myPuzzleCmd2.ExecuteReader() myPuzzleCmd2.ExecuteNonQuery() Catch ex As Exception Response.Write("sp value : " & retRandomCode.Value) Dim iRandomCode(1) As StringReDim Preserve iRandomCode(1) iRandomCode(1) = Convert.ToString(retRandomCode.Value)myPuzzleCmd2 = Nothing Session.Remove("RandomCode") HttpContext.Current.Session("RandomCode") = iRandomCode(1) Response.Write(Session("RandomCode")) Finally myConnection2.Close() End Try End Using
This (demo) statement is fine in Access, and so far as I can see, shouldbe OK in SQL Server.But Enterprise Manager barfs at the final bracket. Can anyone helpplease?select sum(field1) as sum1, sum(field2) as sum2 from(SELECT * from test where id < 3unionSELECT * from test where id 2)In fact, I can reduce it to :-select * from(SELECT * from test)with the same effect - clearly I just need telling :-)cheers,Jim--Jima Yorkshire polymoth
This is probably a very simple question but i would appreciate some helpwith the correct syntax for and update stored procedureI have created user form that allows the user to update the name and address fields in a datatable called customers based on the input value customer ID = ( datatable/Customers)customerIDI have got this far and then got lost:Create SP_UpdateCustomer(@customerID, @name, @address)As Update customers ( name, address)Where customerID = @customerID GOCould anyone tell me what the correct sntax should be.many thanksMartin
I have a test page where I'm using SqlConnection and SqlCommand to update a simple database table (decrease a number). I'm trying to figure out how to make a number in the database table to decrease by 1 each time a button is being pressed. I know how to update the number by whatever I want to, but I have no idea what the correct syntax is for putting variables inside the query etc. Like "count -1" for instance. The database table is called "friday" and the one and only column is called "Tickets". Here's the code behind the button:protected void Button1_Click(object sender, EventArgs e) {SqlConnection conn; conn = new SqlConnection("Data Source=***;Initial Catalog=***;Persist Security Info=True;User ID=***;Password=***"); conn.Open();int count = -1; SqlCommand cmd = new SqlCommand("select Tickets from friday", conn); count = (int)cmd.ExecuteScalar();if (count > 0) { string updateString = @" update friday set Tickets = 500" ; <------ Here I want to set Tickets like "current count -1"SqlCommand cmd2 = new SqlCommand(updateString); cmd2.Connection = conn; cmd2.ExecuteNonQuery(); } else { } conn.Close(); }
I am having trouble finding the correct syntax to access a variable. I have a variable defined in the Variables window: The variable name is formatedDate. The DataType is String.
I am successfully setting the value of the variable in a Execute SQL Task. The SQL is as follows:
SELECT LEFT(CONVERT(VARCHAR, MAX(ReportDate), 120), 10) as formatedDate from DimReportDates
The Result Set is set to “Single Row” and properly set up.
No problem so far. I can see with a watch that the variable has the correct value, something like:
‘2015-09-30’
Now, in a subsequent step, a Data Flow Task, I want to access the variable. Actualy it is in the SQL statement of a OLE DB source in the Data Flow… I have the following:
Hello,I've been searching the web for quite some time to resolve the problemof "1/1/1900" returning in a datetime field in SQL that resulted from ablank (not NULL) value being passed to it through an ASP page.The solution is that a NULL value needs to passed to SQL from ASP.Thats fine...I understand the why the problem is happening and thesolution around it. HOWEVER, I can't seem to get the proper syntax towork in the ASP page. It seems no matter what I try the "1/1/1900"still results. Below are a few variations of the code that I havetried, with the key part being the first section. Does anyone have anysuggestions?!?!?______________cDateClosed = ""If(Request.Form("dateClosed")= "") ThencDateClosed = (NULL)end ifsql="UPDATE rfa SET "&_"dateClosed='"& cDateClosed &"', "&_"where rfaId='"& Request.Form("RFAID")&"'"_____________________________cDateClosed = ""If(Request.Form("dateClosed") <> "") ThencDateClosed = (NULL)end ifsql="UPDATE rfa SET "&_"dateClosed='"& cDateClosed &"', "&_"where rfaId='"& Request.Form("RFAID")&"'"_____________________________cDateClosed = ""If(Request.Form("dateClosed")= "") ThencDateClosed = NULLend ifsql="UPDATE rfa SET "&_"dateClosed='"& cDateClosed &"', "&_"where rfaId='"& Request.Form("RFAID")&"'"_______________Thanks in advance!!!!
I'm looking for the correct syntax to pull back duplicate vendors based on 6 fields from two different tables. I want to actually see the duplicate vendor information (not just a count). I am able to pull this for one of the tables, something like below:
select * from VendTable1 a join ( select firstname, lastname from VendTable1 group by firstname, lastname having count(*) > 1 ) b on a.firstname = b.firstname and a.lastname = b.lastname
I'm running into issues when trying to add the other table with the 4 other fields.
What is the minimum SQL install required for dtsrun? Can I get away with copying a few files and not installing SQL.
Basically, the central SQL database has a DTS package which I need to enable a number of users to run. What I do not want to do is have to install SQL Server on all the end users computers.
We need to schedule a dtsrun batch to run on several servers at the same time. Can someone tell me how to write this in my command prompt so it will run remotely.
Question with DTSRUN 1) I have a batch file which runs a DTS package. Problem is after completion of the package the control doesn't return to command prompt. Any idea how to tackle this.
2) Even on the same server /U /P doesn't work. It errs out saying password is incorrect, Although I can connect to ISQL with same credentials.
I am trying to run two dts jobs using a batch file obviously using dtsrun but im having trouble. I've never attempted this before and it looked easy but not as easy as I thought.
I have two dts jobs, call them package1 and package2. I also saved these as .dts files. I made a .bat file and put it in the same location as the .dts files.
My batch file looks like this:
dtsrun /F package1 dtsrun /F package2 pause
This does not work and I get the following:
C:WINDOWS>dtsrun /F package1 DTSRun: Loading...
Error: -2147287038 (80030002); Provider Error: 0 (0) Error string: The system cannot find the file specified.
Error source: Microsoft Data Transformation Services (DTS) Package Help file: sqldts80.hlp Help context: 704
Can anyone help and tell me what I am doing wrong?
Hello all, I am trying to run a DTS package from a .DAT file and in my file this is my code:
DTSRun /S ServerName /E /N "Promo Point Adjust - Import promo file"/ But when I run that the data in the table is not being updated. my question is -how to I step through the to see what the disconnect is? -Or if there is an error that is happening but being displayied?
when I run the following in sql Analyzer :dtsrun /S"Local" /Ntestemail /UExternalRO /P"changmail"got this error:Server: Msg 170, Level 15, State 1, Line 1Line 1: Incorrect syntax near '/'.Is the command right?And how to run this dts package in commandline?Thanks
I have created a very simple DTS package to transfer data from one database to another on the same server. I am able to successfully execute the package from DTS. But if i try to schedule the package and run it from SQL agent it fails. The job that is created by the SQL agent appears as follows -
I have a question about dtsrun hoping someone have an answer. Does anyone know if there is a switch that I can turn onoff so that it will suppress the output result when I execute the dtsrun ulitity?
output --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- DTSRun: Loading...DTSRun:Executing...DTSRun OnStart: Copy Data from Results to [Transplus_TestArchive].[dbo].[SG_DISPUTE] Step DTSRun OnProcess: Copy Data from Results to [Transplus_TestArchive].[dbo].[SG_DISPUTE] Step; 14 Rows have been transformed or copied.; PercentComplete = 0; ProgressCount = 14 DTSRun OnFinish: Copy Data from Results to [Transplus_TestArchive].[dbo].[SG_DISPUTE] Step DTSRun: Package execution complete. (6 row(s) affected)
Hello! Here's a problem I'm having with user's laptop. I installed SQL Server 7.0 client tools long time ago so she was able to use dtsrun utility. Recently we moved our production database to the new server. The difference between new server and old one is SP. The old server had SP1 for MSSQL Server 7.0 and new server has SP2.
The DTS packages were copied from old server to new one and recreated accordingly.
Then when user was trying to run dtsrun utility she was getting error "Parameter is incorrect". Then I applied SP2 to her SQL installation. After that we've got different error message "Can not create COM server to load DTS package. Class not registered".
I tried to register following files dtsffile.dll,dtspkg.dll,dtspump.dll,axscphst.dll using regsvr32 but I coudn't-I was getting errors.
Then I reinstall SQL client tools and applied SP2 again-still same error about COM server.
Any ideas what else can be done or changed to fix it? Thank you
P.S.this user has another computer. Applying SP2 to her SQL client installation fixed "Incorrect parameter" error and dtsrun works fine on this machine.
Thanks for any help on this matter in advance. I have a DTS Package that when I run from within the MMC it runs fine but when I schedule the job from the DTS design window or create a new job via SQL Agent and use dtsrun.exe with the correct parameters I get the following error:
Dts Owner is sa Sa is also listed as owner for the job. I tried changing the provider to ODBC for SQL Server since error message indicated a provider error and that did not work. I searched Technet for 4001, provider error, dtsrun and got nothing relative. It would seem like a rights issue but SQL Agent Logs on as a local administrator for the SQL box which is also the PDC.