Hi everyone,
While creating a stored prodecure, I now that it is possible to use an output parameter which is a table. However, I do not know how to do it ??
In other words, I would like to return a table but as an output parameter, so how can this happen ?
I have Lookup task to determine if source data should be updated to or insert to the customer table. After Lookup task, the Error Output pipeline will redirect to insert new data to the table and the Output pipeline will update customer table. But these two tasks will be processing at the same time which causes stall on the process. Never end.....
The job is similiart to what Slow Changing Dimention does but it won't update the table at the same time.
First some background info. SQL Express Visual Studio 2005
VB.Net
Data.SQLClient Namespace
Well I was using the OUTPUT option in my program and it was great, i was returning my PrimaryKey from the newly inserted row. (I am using paramaters in my program and running a sqlCommand.ExecuteScalar)
I added trigger to the tblInfo, that after a Insert,Update, Delete it would perform a audit on the table saving the old info that was overritten, type of action taken (insert, update or delete), and who did it.
Well my OUTPUT didn't like that says, it can't do a OUTPUT on a table with a trigger.
--Error msg Msg 334, Level 16, State 1, Line 1 The target table 'tblInfo' of the DML statement cannot have any enabled triggers if the statement contains an OUTPUT clause without INTO clause.
So what am i supose to do? I want the audit to occur, but I walso want the primarykey without doing a select (maxID) which could potentially get the wrong id (multiuser).
I used the oTable.Script method to output the DDL for a Sql Server 2000 user defined table. The result is DDL with an error. I don't think the problem is with DMO itself so I posted this here. Note the 'TEXTIMAGE_ON ' clause. The table does not have a text column, and the DDL will not execute.
CREATE TABLE [MyTable] ( [FilterID] [int] IDENTITY (1, 1) NOT NULL , [LoanAgentID] [int] NOT NULL , [Key] [varchar] (16) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL , [IsActive] [int] NOT NULL , [tStamp] [timestamp] NOT NULL , [Formula] [varchar] (4000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL , [_AuditAddDt] [datetime] NOT NULL , [_AuditUpdateDt] [datetime] NOT NULL , CONSTRAINT [PK_MyTable] PRIMARY KEY CLUSTERED ( [FilterID] ) WITH FILLFACTOR = 90 ON [PRIMARY] ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] GO
Server: Msg 1709, Level 16, State 1, Line 1 Cannot use TEXTIMAGE_ON when a table has no text, ntext, or image columns.
I run a SQL query to select a few colums of data using a select statement, I want the output to be stored in the new table which can be defined in the SQL statement how can I do it?
I've been looking into using the ability to select the table of an OLEDB destination task based on a package variable but would like to know if this could be utilised in the following example.
I have a CSV file (potentially there are many) with a number of rows. The rows do not necessarily contain the same number of elements. Each row has an EventID and this is used to determine the database table that the row is to be inserted in.
Initially i thought about using a conditional split to send each row down the path relating to its event ID. There would be multiple destinations depending on the table. With the possibility of 60 to 70 different event ID's this is very quickly going to get out of hand in the designer. I'd like to know if it would be possible to set up a case statement (or similar) in a script component and specify the table name as a variable depending on the event ID. I'd then use this table variable to set the destination task's table property.
Does this sound like a possibility or do i have to go down the route of multiple paths?
I want to retrieve staff who attend less than 80% for a meeting type assuming we have 10 meetings per list.
Meeting Table:
staffID list date ------------------------ 1 A 2013-01-15 2 B 2013-01-17 1 B 2013-01-17 1 A 2013-01-18 2 B 2013-01-19 1 A 2013-01-20 2 C 2013-01-21
* 1 - Dan * 2 - Jane
When the staffID occur 3 times (70%), query will Output:
staffName list Participation% ------------------------ Dan A 70
SELECT a.staffName, b.list, (100 - ((COUNT(c.staffID) * 100) / 10)) AS 'Participation%' from Staff AS a, listType AS b, Meeting AS c where a.staffID = c.staffID AND b.list = c.list GROUP BY a.staffName, b.list HAVING COUNT(c.staffID) > 2
Server: Msg 8928, Level 16, State 1, Line 1 Object ID 1513928615, index ID 0: Page (3:33709) could not be processed. See other errors for details. Server: Msg 8944, Level 16, State 1, Line 1 Table error: Object ID 1513928615, index ID 0, page (3:33709), row 0. Test (ColumnOffsets <= (nextRec - pRec)) failed. Values are 95 and 30. DBCC results for 'Result'. There are 41589306 rows in 660667 pages for object 'Result'. CHECKTABLE found 0 allocation errors and 2 consistency errors in table 'Result' (object ID 1513928615). repair_allow_data_loss is the minimum repair level for the errors found by DBCC CHECKTABLE (LASAR2.dbo.Result ).
Is there an example anywhere of how to output selected fields in a sql table to a text file with fixed length fields. ie pad data out to required length.
I am trying to create a csv file without the field header information. First, I hid the table header row, then each column header separately, then removed the table header alltogether, but when I print to a CSV file the field headers still show up. This file is going to be use as input to another application and they do not want the header information.
maybe you can help me with a little SSIS task. I want to fetch some wmi infos from serveral servers with the wmi reader. to read something is no problem, but whats the best way to bring them to a table or the control flow? Read from the generated file cant be a way. I also tried the variable. How do I get them to data flow. I tried a script task but i cant read the resultset. What format has the variable? ado.net, ado? Whats the best way to get the results into a table?
Hi Friends, I am new to reporting services . In Excel reports we can create pivot tables and manipulate data easily. Is it possible to create the pivot table in HTML output in SQL Server 2005 without changing the existing procedure or function? I wonder if there is any drag and drop facility to do the same in HTML report. Hope , some one might have dealt with this.
Hi, Is it possible to store the output of a SQL Server 7.0/6.5 System Stored Procedure (eg. xp_fixeddrives, sp_spaceused, etc.) in a table, possibly with a Select Into? All help will be greatly appreciated. Thanx in advance. Craig
I am creating queries and reports in an Access front end (let the groans begin)...it is what they gave me to work with!
This particular query is pulling information from several different tables and manipulating it the way I want. However, there is one table that I am trying to pull info from that has the data arranged differently than all the others.
e.g.:
Name Drive Capacity Free_Space Computer A C 40 10 Computer A D 200 175 Computer B C 80 55 Computer B D 500 445 Computer B E 500 365
I want that to look like:
Computer A C 40 10 D 200 10 Computer B C 80 55 D 500 445 E 500 365
I would prefer to do this within the existing query, without creating a new (permanent) table because the info needs to be real-time.
Currently running Sql Server 2005Is it possible to issue the delete command and capture the affected rows asxml types that will be stored in an audit table with an xml column?Something along the lines of:delete from source_tableoutput(deleted.*into audit_table (xml_audit_column)for xml auto)where source_table.column = @delete_value
To get the results of a stored proc into a table you always had to know the structure of the output and create the table upfront.
CREATE TABLE #Tmp ( Key INT NOT NULL, Data Varchar );
INSERT INTO #Tmp EXEC dbo.MyProc
Has SQL 2012 (or SQL 2014) got any features / new tricks to let me discover the table structure of a stored procedure output, - i.e treat it as a table
EXEC dbo.MyProc INTO #NewTmp or SELECT * INTO #NewTmp FROM ( EXEC dbo.MyProc )
I've the following T-SQL block that I'm executing where I want to print the following output in next line but not sure how to do this:
This is printing everything in one line: SET @BODYTEXT = ' Dear ' + @fname +',We realize you may have taken ' + @course_due + ' in '+ @month_last_taken +'.'
How do I do this: SET @BODYTEXT = ' Dear ' + @fname + ',We realize you may have taken ' + @course_due + ' in '+ @month_last_taken +'.'
Also how can I create a table in this variable, something like this:
(TABLE) LIST THE COURSE CODE, COURSE NAME , EMPLOYEE ID, EMPLOYEE NAME
(Course Name) (Last Completed) (Now due in Month/year)
My T-SQL code:
DECLARE @email varchar(500) ,@intFlag INT ,@INTFLAGMAX int ,@TABLE_NAME VARCHAR(100) ,@EMP_ID INT ,@fname varchar(100)
insert into Test123 values(1,'Name','X') insert into Test123 values(1,'Age',50) insert into Test123 values(1,'Salary',1000) insert into Test123 values(2,'Name','Y') insert into Test123 values(2,'Age',30) insert into Test123 values(2,'Salary',2000) insert into Test123 values(3,'Name','Z') insert into Test123 values(3,'Age',35) insert into Test123 values(3,'Salary','One Hundred')
And I want output in below format.
AttributeValueType ================= AGE | NUMERIC NAME | ALPHABET SALARY | ALPHANUMERIC ==================
I need to transform Foxpro table to SQL Server table with merging all rows into one where all column values are the same except one . For this the only column with the different values , I want them also to be merged as coma or space delimited string. The question whether SSIS is a good candidate for this kind of data munging and also would be interested to know knowing as many as possible ways of doing that. Surely I may produce Foxpro script in 5 minutes which wil do that and be a pre-processor action before SSIS starts.
I've a requirement to store the output of the stored procedure into temp. tables/ table varibles. I've 4 select statements as my output of the stored procedure. How do I store the results of all the 4 select stmnts into 4 different temp tables.
Simplified SP is as...
Create procedure usp_test as begin
select c1,c2 from table1 select c3,4 from table2 select c9,c8 from table3 select c5,c7 from Table4 end
I'm expecting something like this...
declare @table1 table (c1, c2) insert into @table1 Exec <Sp_Name>
select * from @table1
I know the above stmnt works, if my SP has only 1 select stmnt as output. Please help me to acheive this for multiple select statements.