SP Is Not Reading The Table Name?
Aug 23, 2006
-- drop proc SP_Trio_Popul_Stg_Tbls1
CREATE PROC [dbo].[SP_Trio_Popul_Stg_Tbls1] @tableName varchar(20) AS
-- alter PROC [dbo].[SP_Trio_Popul_Stg_Tbls1] @tableName varchar(20) AS
declare @sql varchar (20)
set @sql = 'INSERT INTO dbo.Name_Pharse_Stg_Tbl1 (nm_last)
SELECT nm_name FROM dbo.' + quotename(@tableName)
print @sql
exec (@sql)
----------------------------------------------------------------------
exec SP_Trio_Popul_Stg_Tbls1 '00485'
----------------------------------------------------------------------
INSERT INTO dbo.Name
Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near 'Name'.
im trying to run this SP but im getting an error. Can you help me to fix it?
-------------------------
gongxia649
-------------------------
View 20 Replies
ADVERTISEMENT
Apr 8, 2005
I receive in a table a field which is an xml string
like below
<NewOrder><SiteID>CJC</SiteID><patID>458887</patID><LName>Cronin</LName><FName>tim</FName><EntryID>{7B1A4946-CEC8-4F23-AE89-5C70A6A0F9B2}</NewOrder>
Is there a way read this field with a select statement? I need to strip out the entryid value in a trigger
View 4 Replies
View Related
Feb 16, 2008
I need to select all the records in a table, loop through them one by one, calculating some new field data, and then write the new data back to the same table. Here is the basic structure of what I've come up with:<CODE>SqlCmd = SqlConn.CreateCommandSqlStatement = "SELECT ProductID, Name FROM tblProducts"SqlCmd.CommandText = SqlStatementSqlRdr = SqlCmd.ExecuteReaderIf SqlRdr.HasRows Then While SqlRdr.Read If SqlRdr.FieldCount > 0 Then ... SqlWriteCmd = SqlConn.CreateCommand SqlStatement = "UPDATE tblProducts SET Name = '" & NewName & "' WHERE ProductID = " & CStr(ProductID) SqlWriteCmd.CommandText = SqlStatement SqlWriteCmd.ExecuteNonQuery() SqlWriteCmd = Nothing End If End WhileEnd IfSqlRdr.Close()SqlCmd = Nothing </CODE>I get an error that tells me to close out the Reader before trying to execute the write query. But I can't close it out for the loop to work properly. So I assume that there must be another way to do this simple task, but I'm so new to all of this that I need some help! Thanks!
View 1 Replies
View Related
Feb 2, 2006
Hi
I need to read a very big table more than 60,000 record but it is giving the following problem: But if it is small table there is no problem. Same problem also views.
Server Error in '/POBuilds' Application.
Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine. Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".
<!-- Web.Config Configuration File -->
<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.
<!-- Web.Config Configuration File -->
<configuration>
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
</system.web>
</configuration>
View 1 Replies
View Related
May 1, 2007
Hi,I'm using a 3rd-party app's back end which stores SQL statements in atable, so I have no choice but to use dynamic SQL to call them (unlesssomeone else knows a workaround...)Problem is, I can't get the statement to run properly, and I can't seewhy. If I execute even a hard-coded variation likeDECLARE @sql nvarchar(MAX)SET @sql ='SELECT foo FROM foostable'sp_executesql @sqlI get: Incorrect syntax near 'sp_executesql'.If I runsp_executesql 'SELECT foo FROM foostable'I get: Procedure expects parameter '@statement' of type 'ntext/nchar/nvarchar'.which I understand, as it's omitting the N converter--so if I runsp_executesql N'SELECT foo FROM foostable'it's fine. I don't understand why the first version fails. Is it somesort of implicit conversion downgrading @sql? Every variation of CASTand CONVERT I use has no effect.This is SQL Server 2005 SP2. Thanks in advance.
View 11 Replies
View Related
Feb 13, 2007
I want to (and succeeded) read information from one table in my database ([services] in this case) and display them in a table with an additional column with a textbox so that I can enter volumes in it. So far so good, this works fine. But I now want to store all the volumes together with the ID's in a seperate table ([service_volume]) by clicking the Submit button.
Does anyone know how to achieve this?
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Show Services</title>
</head>
<body>
<form id="form1" runat="server">
<asp:Repeater
id="rptVolumes"
runat="server"
DataSourceID="SqlDataSource1">
<HeaderTemplate>
<table border="1" width="100%">
<tr>
<th>Service ID</th>
<th>Service Name</th>
<th>Volume</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><asp:Label id="lblService_ID" runat="server" Text='<%#Eval("service_id")%>'></asp:Label></td>
<td><asp:Label id="lblService_Name" runat="server" Text='<%#Eval("service_name")%>'></asp:Label></td>
<td>
<asp:TextBox id="intVolume" Runat="server" />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
<asp:Button ID="Button1" runat="server" Text="Submit" OnClick="btnStoreInfo" />
</FooterTemplate>
</asp:Repeater>
<asp:SqlDataSource
ID="SqlDataSource1"
runat="server"
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="SELECT [service_id], [service_name] FROM [services]">
</asp:SqlDataSource>
</form>
</body>
</html>
View 1 Replies
View Related
Jan 14, 2002
Hi ... I need to read rows from a large source file , check if the data selected already exists in the destination and if it does, upate the destination , else insert a new row . Now i could use a sp, but that means i have to call it for each row in the text file ...
any ideeas on what kind of package can be created /
cheers
benjamin
View 1 Replies
View Related
Aug 17, 2000
What is the best way to read and edit data in the tables of a sql server 6.5 database?
Thanks
Gunnar
gunnardl@yahoo.com
View 1 Replies
View Related
Jan 21, 2015
I am trying to think of a way to read a control table, build the SQL statement for each line, and then execute them all, without using a cursor.
To make it simple... control table would look like this:
CREATE TABLE [dbo].[Control_Table](
[Server_Name] [varchar](50) NOT NULL,
[Database_Name] [varchar](255) NOT NULL,
CONSTRAINT [PK_Control_Table] PRIMARY KEY CLUSTERED
[Code] ....
So if we then load:
insert into zt_Planning_Models_Plant_Include_Control_Table
values ('r2d2','planing1'), ('r2d2','planing7'), ('deathstar','planing3')
Then you would build a SQL script that would end up looking like the following (note all the columns are the same):
insert into master_models
Select * from r2d2.planning1.dbo.models
insert into master_models
select * from r2d2.planning7.dbo.models
insert into master_models
Select * from deathstar.planning3.dbo.models
View 3 Replies
View Related
Jul 17, 2013
I have a subselect that should be working but doesn't. Been at it too long today.
DECLARE @Calendar1 AS DateTime
SET @Calendar1 = '{{{ Please choose a start date. }}}'
SELECT
('0' + CONVERT (varchar (10), W.WorkerID)) AS VendorID,
(W.FirstName + ' ' + W.LastName) AS VendorName,
(W.FirstName + ' ' + W.LastName) AS Contact,
[code].....
Where did I go wrong?
View 3 Replies
View Related
Apr 15, 2015
How to read multiple excel sheets in same excel file with different table schema.
Basically need to load data into tables from these excel sheet.Â
So I know how to dynamically read multiple excel sheets in same excel file with same table schema and load into one table.
But how to do this dynamically for multiple excel sheet with different table schema and load into different tables?
View 7 Replies
View Related
Jul 16, 2007
hi guys, Can anyone advise me how how to read an excel doc i have stored locally? I need to be able to start the read from say row number 6 and finish the read once i get to a row that contains a pre-determined word signifying the end of processing. I intend to store the parsed data in an array that will be used as the data source for a gridview or repeater object on another asp page. I'm using ASP.net 2.0 and C# by the way. thanks in advance for any help!!!
View 12 Replies
View Related
Jan 13, 2004
Why won't this dataReader read?
Dim objCon2 As New SqlConnection()
objCon2.ConnectionString = "a standard connection string"
objCon2.Open()
Dim objCommand As SqlCommand
objCommand = New SqlCommand(strSQL, objCon2)
Dim objReader As SqlDataReader
objReader = objCommand.ExecuteReader()
Label1.Text = objReader("email")
strSQL is a select command which I've checked (using SQL Query analyzer) does return data. I know the connection string is valid (and I presume if it wasn't that it'd fail on objCon2.open, which it doesn't).
So why oh why do I get this error on the last line (and yes, there is an "email" field in the contents of the reader)
System.InvalidOperationException: Invalid attempt to read when no data is present.
View 1 Replies
View Related
Jun 29, 2005
I have this code that I hacked together from someone else's example. I kind of understand how it works. I just don't know if it will and i am not in a location right now to check. I was wondering if I did this correctly first, second how can it improve and should i do something different. Basically i just want to check the password in a database. I am passing the username and password to this function from another functioprivate bool authUser(string UserName, string Password){ string connectionString = ConfigurationSettings.AppSettings["DBConnectionString"]; SqlConnection DBConnection = new SqlConnection(connectionString); bool result = false; DBConnection.open() SqlCommand checkCommand = new SqlCommand("SELECT password FROM Users WHERE userName='" + Password + "', DBConnection) SqlDataReader checkDataReader = checkCommand.ExecuteReader();
if(checkDataReader.GetString(0) == Password) { result = true; } else { result = false; } checkDataReader.Close(); DBConnection.Close();
return result;}Thank you Buddy Lindsey
View 6 Replies
View Related
May 30, 2001
Does anyone know how to read transaction log besides trace and profiler. The current situation is some one in our org. deleted an item and I'm trying to find out who and when.
View 2 Replies
View Related
Feb 9, 2000
I have some records that have been deleted. I need to find out who did it and to do that I need to read the logs. Are there any utilities that will allow me to read login 7.0? How about 6.5?
Chris
View 2 Replies
View Related
Dec 22, 1999
Here is I think an interesting question
is there a way to read or access the transaction log of a
database in SQL server 7.0
Hoping someone has a solution :-)
View 5 Replies
View Related
Nov 2, 1999
We are having continual problems with our transaction log filling up on one of our major applications.
Does anyone know of a way or tool to read the transaction log? We want to determine what is causing this problem.
Thanks
View 3 Replies
View Related
Jul 12, 1999
Is there a way, in SQL 7.0 to print out or view what's in the Transaction Log? In 6.5 you could view the table syslogs, but I don't see any documentation anywhere on how to do this in 7.0.
View 1 Replies
View Related
Aug 23, 2001
I received a SQL Server 6.5 database (.dat file) on a removeable drive. I'm currently running 7.0. Is there any way to read/import/link to this data without installing 6.5. And if I have to install 6.5 how do I get the system to see the database?
View 1 Replies
View Related
May 24, 2002
Hello people;
Somebody knows some utility where I can read the Transaction Log Sql 2000 ?
Thanks;
Navlig®
View 1 Replies
View Related
Jun 10, 2002
Hi
How can I read an ini file entry and pass this parameter to a stored procedure which will be run in a DTS Package?
Thanks for the input
mipo
View 2 Replies
View Related
Sep 19, 2001
Anyone know a way to read DTS packages? I have inherited a DTS package, saved in SQL, and am trying to find a way to read the steps without having to view every single step through the GUI.
Thanks in advance.
View 3 Replies
View Related
Sep 1, 2006
Hi,
I need to know that how can we read ClientProcessID (älso use used in SQL Profiler).
Regards,
Shabber.
View 2 Replies
View Related
May 20, 2008
Hi. I want to write a function to retrieve all records from a "Parts" table so that I can read these records in .NET.
SqlDataReader reader = sqlCmd.ExecuteReader()
while( reader.Read() )
{
int x = reader["id"];
string partName = reader["name"];
// Do stuff with data here //
}
My question: How should the function be written?
Should I create a PROCEDURE and just call a SELECT statement?
CREATE PROCEDURE getPartsList()
AS
SELECT part_id as 'id', part_name as 'name' FROM parts
Or should I create a FUNCTION that returns a TABLE? If so, is this the correct syntax?
CREATE FUNCTION getPartsList()
RETURNS TABLE
AS
RETURN (SELECT part_id as 'id', part_name as 'name' FROM parts)
Thanks for reading
View 3 Replies
View Related
Jun 9, 2014
The requirement is to read XML element from database column.The column looks like
<ClMetadataDataContract xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.cch.com/pfx.net/psi/">
<EntityType>1</EntityType>
<NameLine1>David Jones</NameLine1>
[code]....
I have also tries OPENXML but no luck
View 2 Replies
View Related
Jun 22, 2008
How do I view the SQL 2005 transaction log file(.ldf)?
Is there a built-in utility?
Thank you
View 3 Replies
View Related
Jun 24, 2008
I am storing one text file on the server.This text file contains some mobile numbers.The file look like
009198XXXXXXXX
009198XXXXXXXX
009198XXXXXXXX
009198XXXXXXXX
etc
Here I need to read this text file row by row mobile number and then insert these mobile numbers into a table by using sql procedure or sql trigger or any other method or coding. Is it is possible or not?
If so then anybody can help me!
regards
Shaji
View 4 Replies
View Related
Jul 13, 2006
Hello friends...
We have sql server 2000 and i need to read one perticular xml and from that i want ID field stored in one table...is it possible by query analyzer to read xml and stored ID in table...I have only path of that xml file...
like
select ID from ("D:XMLFolder*.xml)
that i want
View 2 Replies
View Related
Jul 17, 2007
Hi All,
I would like to know if i can read data from xl sheet using a stored procedure?
Thanks in advance
vishu
View 17 Replies
View Related
Jul 25, 2007
Hi,
I've been a developer for 20 some years, but never learned the design steps of a complex database. Can you give me a book or 2 to bring me up to speed with the latest database design and data modeling techniques?
thanks.....
View 3 Replies
View Related
Feb 28, 2007
I do a lot of file processing and I usually run a little script I copyand paste to read directory information to see if a new file it thereand then process the file if it is. So, I decided to wise up and makea stored procedure to automate a lot of that.The pivotal step in this is that i run a command that looks like:CREATE TABLE #DIR (FileName varchar(100))DECLARE @Cmd varchar(1050)SET@Cmd = 'DIR "' + @Path + CASE WHEN RIGHT(@Path, 1) = '' THEN ''ELSE '' END + @WildCard + '"'INSERT INTO #DIREXEC master..xp_CmdShell @CmdWhen I run the stored procedure I get back the files and folders inthere that match the wildcard and all is good!!!!....Until I try to put that information into a table while calling thatstored procedure:CREATE TABLE #Files (Path varchar(100),FileName varchar(100),PathAndFileName varchar(150),FileDateTime SmallDateTime,FileLength int,FileType Varchar(10))INSERT INTO #FilesEXEC sp_GetFileNames @Path = '\isoft2ftpLegacyBilling', @Wildcard= '*.txt'When I run this I get:Server: Msg 8164, Level 16, State 1, Procedure sp_GetFileNames, Line53An INSERT EXEC statement cannot be nested.Because I use an INSERT EXEC to with the results from the @Cmd.Anybody have any ideas how I can get that information into a table?I did try to just copy the data to c: empdir.txt and then bulkimport it in. But when it runs the @Cmd to create the file it comesback with a NULL value and my stored procedure returns two sets ofvalues... which I can't do.So, I would appreciate anybody who can help.Thanks!-utah
View 4 Replies
View Related
Jul 20, 2005
Hi,How can i read information in Transaction Log in SQL Server 2000?Thanks
View 1 Replies
View Related