Create Variables With Same Format In One Single Step?

Jul 23, 2005

I would need to create multiple variables with the same format for
future update, what I did is listing them separately, is there an easy
way to combine them in one step? please see query below. Thanks a lot!

--Current Query--
SELECT cast(0.0 as money) as balance_1
,cast(0.0 as money) as balance_2
,cast(0.0 as money) as balance_3
,cast(0.0 as money) as balance_4
,cast(0.0 as money) as balance_5
,cast(0.0 as money) as balance_6
,cast(0.0 as money) as balance_7
,cast(0.0 as money) as balance_8
,account_no
,XXX
INTO table1
FROM account

Can I do something like this? This one didn't work.

SELECT balance_1 to balance_8 (cast 0.0 as money)
,account_no
,XXX
INTO table1
FROM account

View 5 Replies


ADVERTISEMENT

Step-by-step Deployment Of Single-user Database App?

Mar 2, 2008

Hi!

I hope the answer is as simple as the question -- but after reading all the documentation I could find (understand?) and a lot of posts here, I'm no closer to achieving the goal.

I have a Visual C# app, DAYTRACKER, developed in VS2005. It uses a database with several tables constructed using SQL Server 2005 Developer Edition.

I want to deploy the app plus the database plus SQL Express to another machine, to be used by a single user (the administrator) with no need for network connectivity of any kind.

What I have so far is:
1. The application is successfully deployed from a CD-ROM, having used the Publish process within VS2005, and opens on the new machine -- without database connectivity, however.
2. SQL Express is successfully deployed (it deployed as a 'prerequisite' when I went through the Publish process in VS2005)
3. I manually copied the database's .mdf and .mdl files, using SQL Server Managers 'Copy Database' function, then transferred the copies to the new machine into the ..MSSQL.1MSSQLdata folder (where they appear along with the master.mdg, mastlog.ldf etc files)

Now, the DAYTRACKER application's DAYTRACKERConnectionString under 'Settings' in the VS2005 studio reads 'Data Source=DELL3;Initial Catalog=DayTracker;Integrated Security=True' (which are the appropriate parameters for the machine, DELL3, on which I wrote the program.)

The problem, of course, is that SQL Express on the new machine doesn't connect the application to the database. When I go to the 'SQL Server Configuration Manager' and go to the 'SQL Server 2005 Services' and double-click on the 'SQL Server (SQLEXPRESS)' icon (the service is running) and the user is logged on using 'Local System Account'. Under the 'Service' tab the Host Name is 'MUSIC' (which is the name of the new machine I've installed the app onto -- which of course is not the name - DELL3 - that the app's connection string is expecting). Under the 'Advanced' tab, I've tried correcting the name of the Startup Parameters default .mdf and .mdl entries to ..DayTracker.mdf and ..DayTracker_log.mdl, but the server won't start up after I make the changes.

What I'm hoping for: a step-by-step way of doing this type of deployment, preferable getting it all onto one CD-ROM, and installing it on the new machine so that it all works seamlessly from the start, not requiring any 'tweaking' of the SQLServer Express settings by the end-user.

But I'll take pretty much anything that fixes the specific db connectivity problem I've described.

Thank you very much.

John F.

View 11 Replies View Related

Programmatically Setting Package Variables In Job Step Command Line

Mar 1, 2007

We are trying to start a server job running an SSIS package and supply some parameters to the package when we start the job using SMO.

What we have now is this:

string cmdLine = job.JobSteps[0].Command;

cmdLine += @" /SET PackageGetGroupRatingYear_Id.Variables[User::RatingId].Value;1";

cmdLine += @" /SET PackageGetGroupRatingYear_Id.Variables[User::GroupId].Value;1";

cmdLine += " /SET \Package.Variables[User::period].Value;"" + periodEndDate + """;

job.JobSteps[0].Command = cmdLine;

job.Start();

It appears that when the job is run, the modified command line is not used.

What is needed to supply runtime parameters to a job step when starting the job via SMO?

Thanks,

View 3 Replies View Related

UPDATE A Variable To Different Categories By A Single Step?

Jul 23, 2005

Hello,I am trying to update variable 'Type' (which is a pre-defined variablewithout any value in it). Is there a way to combine Step1 to Step3 intoone single Update? I tried the query at the bottom but it didn't work.Thanks a lot!--STEP1:Update TABLE1set type = casewhen name like '%Airline%' then 'Airlines'else 'Others'end--STEP2:update TABLE1set type = casewhen name like '%Brokerage%' then 'Brokerage'else 'Others'endwhere type = 'Others'--STEP3:update TABLE1set type = casewhen name like '%card%' then 'Credit Card'else 'Others'endwhere type = 'Others'--Failed query:Update TABLE1set type = casewhen name like '%Airline%' then 'Airlines'else when name like '%Brokerage%' then 'Brokerage'else when name like '%card%' then 'Credit Card'else 'Others'end

View 6 Replies View Related

How To Execute A Single Step In A SSIS Package?

Mar 17, 2007

Hi all,

I am new to SQL Server 2005 (but many years in SQL Server and .NET), and I am sort of having everything figured out for my company. However, one thing that still bothering me is that:

In the old Server 2000, you can execute a single step in a DTS package by right click the step and then click execute step.

In the new server 2005, I can only execute the whole package from the Management Tool and Edit the pack from VS 2005. Is there also a way for me to execute a single step in a SSIS package?

This is important for us, many thanks!





View 11 Replies View Related

SQL Security :: Easiest Way Of Have A Single Job Step Run Under A Different Login?

Jul 20, 2015

I want to run a SQL Agent step as a different user than the one used by the Agent service.  I thought that I would create a new credential and then have a proxy use it, however there are none for just plain old SQL.  This is a SQL 2014 Enterprise instance. The reason for this is that I the Windows login that is used by the Agent service is not defined as a login in the database, I don;t want to therefore add it in as a user with restrictive rights it case it impacts on other jobs.  What is the easiest way of have a single job step run under a different Login? 

View 7 Replies View Related

Unable To Create A Step In A SQLServer Job

Jul 23, 2005

I am running SQLServer 2000 SP3 with MDAC 2.8.On instances created via MSDE, I am unable to create the first step ina job. Instances created with SQLServer 2000, this problem does notoccur.The message I am receiving on the instances created with MSDE, themessage I get immediately upon pressing the Add button to define a stepis "Error 170: Line 1: Incorrect syntax near ''"Any help would would be greatly appreciated.Wardell Castles

View 4 Replies View Related

Sample Files From The Book SQL Server 2005 Reporting Services Step By Step

Jan 18, 2008



Hi All,

Please let me know where can i find the sample files and rs2005sbsDW database in msdn library as i dont have CD provided along with the book.

Please give me the link of the sample files so that i can download it for testing the sample application.

Regards,
Prabhanjana

View 1 Replies View Related

Step By Step SQL2000 Failover Cluster Upgrade To SQL2005

Oct 13, 2006

is there such a paper? if so, can you pls point me to it? thx in advance

View 4 Replies View Related

Step By Step To Publish/deploy The Report Project To The User Pc ?

Oct 3, 2007

hye everyone,

after finished do the report and deploy at IIS/report manager in local pc..

i want to know , what is the step /how to deploy the report project at the user's pc/ client pc /other server..


thanks in advance
thank you very much

View 16 Replies View Related

Reporting Services :: How To Convert RDL File To RDLC Step By Step

Jun 18, 2012

I want to convert .rdl  to .rdc need full steps.Actually i created .rdl report using sp sucessfully.Now i want to convert it to rdlc while doing it iam getting some authentication error and some thing else.I created rdl in 2008 and i want to change it to rdlc 2010.

View 5 Replies View Related

Execute Package Results Different To Step By Step Execution - Uses Raw File

Jan 31, 2007

I have a package that has multiple data flow tasks. At the end of a task, key data is written into a raw file (file name stored in a variable) that is used as a data source for the next task. Each task requires a success from the preceding task.

Here's the rub:

If I execute the entire package, the results of the package (number of records of certain tasks) differs significantly from when I execute each step in the package in turn (many more records e.g. 5 vs 350).

I get the feeling that the Raw file is read into memory before it is flushed by the previous task, or that the next task begins preparation tasks too early.

Any help is greatly appreciated.

I am running on Server 2003 64 (although the same thing happens when deployed on a Server 2003 32 machine)

Thanks

B.

View 2 Replies View Related

Create My Own @@Variables

Apr 16, 2008



Does anyone know if there is a way to create a server-wide variable... something like:

declare @@MyVar BIGINT
set @@MyVar = 22456

then refer to this var in any scope throughout the server?


View 7 Replies View Related

How To Read An Database Table Step By Step (with ADO)

May 19, 2008









Hi,
I have to transport a big database table and can't read it at once with "select * from table" because the table is bigger than my system memory.
Is there a way to read the table step by step? I thought it was possible with ADO and his serverside cursors but I don't now how. I need an "universal" solution that works on SQL Server 2000/2005, MySQL and Oracle.

Regards,
harry

View 2 Replies View Related

Enabling T-SQL Debugger (SQL2000) - Step Into, Step Over Etc

Dec 5, 2007

Connecting to a networked SQL Server Box from my local machine


Open Query Analyzer from Start menu, logging in using sa account.

from the object browser i select my stored procedure (WEA_InsertClaim) - right click and select Debug.

i am prompted to enter the parameter values, which i do, auto rollback checkbox is checked - click Execute.

T-SQL Debugger opens and runs through the stored procedure.

but only buttons enabled are the "Go", "Toggle Breakpoint", "Clear All Breakpoints"

so i can set breakpoints etc. but when i select Go it will not stop at the breakpoints it just runs through the stored procedure from start to finish. giving the correct return code as its output

is there something i need to enable in order to make it stop at breakpoints??

Cheers,
Craig

View 3 Replies View Related

Using Variables To Create Views

May 8, 2007

I am stuck on creating views using the variables. I keep on getting the 'CREATE VIEW' must be the first statement in a query batch error. I understand that views need to be the first statement, but I have a lot of views that need to reference specific variables - is there any way to do this?

The code I am using is as follows:

DECLARE @view varchar(MAX)
DECLARE @database varchar(30)
SET @database = 'KateTEST3'

--Insert views
SET @view = 'USE ['+@database+']
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON;

CREATE view [dbo].[userssupplier]
as
SELECT *
FROM dbo.Users
WHERE (User_Type = 4.0) OR
(User_Type = 5.2)'
EXEC(@view)





Thanks

View 11 Replies View Related

Create A View Based On Variables?

Jul 28, 2004

Hi All,

I would like to create a view based on a variable (a date).

CREATE VIEW testView (@myDate)
AS

select * from testTable
WHERE testVar = @myDate

--
This is far from what the final view would look like, but if anyone knows if something similiar to this can be done, I would greatly appreciate it.

Thanks.

View 1 Replies View Related

Create Database Using Local Variables

Feb 4, 1999

I have an installation script and want to create a database based on some data in a table (config). Testing the script though I get a message:

Msg 170, Level 15, State 1
Line 12: Incorrect syntax near '@DBData'.

The relevant sql is:

declare @DBName varchar (40)
declare @DBData varchar (40)
declare @DBLog varchar (40)
declare @DBSize int
select @DBName = obj_txt from config where obj_nm='DBName'
select @DBData = @DBName + '_Data'
select @DBLog = @DBName + '_Log'
select @DBSize = obj_int from config where obj_nm='DBSize'
raiserror('Creating Database %s ....',0,1,@DBName) with nowait

Create Database @DBName
on @DBData = @DBSize
Log on @DBLog = @DBSize

I don't think there's anything wrong, apart from the fact I am using the local variables. Is this allowed on a Create Database statement? I haven't found anything in Technet that may help.

Here's hoping....
Thanks
Dan

View 1 Replies View Related

Concatenating Variables To Create A Column Name

May 5, 2008

I am trying to build a Windows application using: Windows XP Pro ; VS Pro 2005, C# and SQL2005.

I have 2 database table3 as follows:
eg
1) myGameRecency which contains columns : GameId (identity specification column/primary key/not null), Date (not null), [1], [2], [3], [4] , WeeksSinceDr0, WeeksSinceDr1, WeeksSinceDr2
2) myGameFrequency which contains columns : AllBallsFrequency , WeeksSinceDrawnAllBalls

Using the myGameRecencyAllBalls table ---
I wish to insert a 0 into a column corresponding to a ball that has been drawn, eg if a 4 has been drawn, then a 0 will be inserted into that column. If a ball has not be drawn, then the value in that column will be a running total, signifying the number of draws since it was last drawn ( ie since a 0 was inserted into that column).

I place a 1 in the column corresponding to the number of weeks since a number has been drawn. The name of the column is therefore the concatenation of the string literal 'WeeksSinceDrawn' and the value held by the variable, @lastRowCount obtained by the lastrow_CURSOR.

I have declared a variable @colName to hold the concatenation / Set @colName = 'WeeksSinceDr' + CONVERT(nvarchar(max), @lastRowCount) and then tried to use it as follows: SET [@colName] = 1

however, I receive an error message advising me that I have an invalid column name. Is there any means of setting a column name by concatenating two variables or , a string literal and a variable ?

Thank you
lpbcorp


sqlCmd.CommandText = "DECLARE @colName nvarchar(max) " +

"DECLARE @lastRowCount int " +

"DECLARE lastrow_cursor CURSOR SCROLL FOR " +

"(SELECT [" + i.ToString() + "] FROM " + DBGameName.ToString() + "RecencyAllBalls) " +

"OPEN lastrow_cursor " +

"FETCH LAST FROM lastrow_cursor INTO @lastRowCount " +

"SET @colName = 'WeeksSinceDr' + CONVERT(nvarchar(max), @lastRowCount) " +

"IF @lastRowCount <= 175 " +

"BEGIN UPDATE " + DBGameName.ToString() + "RecencyAllBalls SET [@colName] = 1 WHERE Date = '" + Date + "' " +

"END " +

"ELSE " +

"UPDATE " + DBGameName.ToString() + "RecencyAllBalls SET WeeksSinceDrOver175 = 1 WHERE Date = '" + Date + "' " +

"CLOSE lastrow_cursor " +

"DEALLOCATE lastrow_cursor";

sqlCmd.ExecuteScalar();

View 3 Replies View Related

Is It Possible To Dynamically Create Multiple Variables In A Package?

May 21, 2008

I'd like to be able to call different packages from a control flow. These packages will have different requirements for parameters therefore I'd like to create them dynamically.

Is this possible? Can I do it using a script task?

Thanks in advance.
Ben

View 10 Replies View Related

Step By Step For Indirect Configuration

Feb 15, 2006

Is there a good step by step guide to setting up an indirect configuration? I've followed the steps in Kirk Haselden's 'Keep your packages in the dark' article 3 or 4 times this afternoon and nothing seems to work. I cannot even get the XML configuration file to work by accessing it directly. I'm using the wizard to create the file.

Just wondering if there was something else out there....

Thanks in advance for any help.

MarkA

View 3 Replies View Related

SQL Server Agent Job Step Fails When Creating A SQL Server Integration Serveices Type Of Step

Mar 12, 2008

Hi

I posted this on the sql server security forums too. Here is the error that i get when i change the type of the step to ssis

Failed to retrieve data for this request. (Microsoft.SqlServer.SmoEnum)
Additional information:
An exception occured while executing a Transact-SQL statement or batch.
(Microsoft.SqlServer.ConnectionInfo)
The current transaction cannot be committed and cannot support operations that write to the log file. Roll back the transaction
The current transaction cannot be committed and cannot support operations that write to the log file. Roll back the transaction
The current transaction cannot be committed and cannot support operations that write to the log file. Roll back the transaction
The current transaction cannot be committed and cannot support operations that write to the log file. Roll back the transaction
The current transaction cannot be committed and cannot support operations that write to the log file. Roll back the transaction
The current transaction cannot be committed and cannot support operations that write to the log file. Roll back the transaction
The current transaction cannot be committed and cannot support operations that write to the log file. Roll back the transaction
The current transaction cannot be committed and cannot support operations that write to the log file. Roll back the transaction
The current transaction cannot be committed and cannot support operations that write to the log file. Roll back the transaction
The current transaction cannot be committed and cannot support operations that write to the log file. Roll back the transaction.(Microsoft SQL Server, Error: 3930)

This error pops up right after i change the type of the step to "SQL Server Intergration Services Package"

I have made the following configurations:

The user group (windows group) that the user belongs has the following roles in msdb :

db_dtsadmin
db_dtsltuser
db_dtsoperator
SQLAgentOperatorRole
SQLAgentReaderRole
SQLAgentUserRole

i have made a proxy to sql server agent which has the following subsystems :

"SQL Server Integration Services Provider" the proxy is tied to the same login which has those SQLagent and dts roles in msdb database.

Im using windows authentication and the user that logs into the sql server is in the same group that i have set all of the rights.

Ps. Clearly im missing some role or right somewhere because as soon as i give the group sysadmin role then all the users in that group can create SSIS steps in the agent.

Ps. Ps. I have been living under the impression that i dont have to give sysadmin rights to people that create ssis packages and schedule then with the agent.

View 3 Replies View Related

CREATE ENDPOINT To Expose A Single DB Instance

Feb 27, 2007

I have been looking at this statement for allowing access from a remote location to a specific database on my SQL Server (2005) from a client application.
Is it possible to do this using this method? I see lots of examples using this to expose Web Services of DB objects, however I need the client application to be able to authenticate to and access all objects in the database. If so, could some one provide a simple example of the arguments to use? For example, which protocol arguments are valid for this? I would like to use SQL Server Authentication. Is this possible?
 Regards,
 -Troy

View 1 Replies View Related

How To Create A Matrix Of Values From A Single Table

Aug 28, 2013

I'm a real novice user and I we use SQL Server. I have a table called TableLog that has the 4 columns. The first column is repeated x number of times for each value in the second column. I'd like to see this information put into a matrix where I could tell if there are any missing intersections. In addition, I need to insert a WHERE clause that says "BETWEEN 20090000 AND 20100000" for the first and second columns.

Example data in the table:

ID1 ID2 MRSSI
100 200 63
100 300 63
200 100 63
200 300 63
300 100 63

Desired matrix: P = Pass and F = Fail

100 200 300
100 n/a P P
200 P n/a P
300 P F P

From the example data, there's no intersection for 300 and 200 so a F is displayed.

View 3 Replies View Related

How To Create DB For Single Attribute Having More Than 2 Text Fields

Dec 14, 2014

How can we create a DB for a single attribute such as ORDER DETAILS, CASH RECEIPT, TAX INVOICE having more than 2 text fields.

Also, in every form attribute such as order id is not present - in order identify the same as a primay key. So, which other attributes or fields can be considered as a primary key.

View 5 Replies View Related

Reporting Problems W/ MS SQL Server 2005 Reporting Services Step By Step To MS

Apr 26, 2007

I am trying to learn Reporting Services using the title "MS SQL Server 2005 Reporting Services Step by Step" by Stacia Misner and Hitachi Consulting, published in 2006. I am experiencing problems with some of the exercises. I got as far as Chapter 4 when I followed directions to create a SQL statement to define a query string for a dataset. Pg 80:



select * from vProductProfitability

where year = 2003 and

MonthNumberOfYear = 1



The view vProductProfitability does not exist in the tutorial database that came with the book, rs2005sbsDW. The result of this query is the basis for the entire chapter on developing basic reports and I'm being denied a learning opportunity because the view does not exist. In short, I'm stuck.



I have tried to find somewhere at Microsoft to place this question and get some answers so I can continue thru the tutorial. To no avail. Does anyone have any suggestions?



BTW, the solution that came in the CD is also wrong because the query noted above is also in the solution.



This humble grasshopper seeks wisdom.



Respectfully Submitted,



Dave Matthews

Atlanta, GA

aka FlooseMan Dave

View 17 Replies View Related

Create New Table Format

Jan 11, 2006

Im new / novice user to writing SQL scripting. I have two tables and table1 has two columns

uslid and groupid,

uslid1, group1

uslid1, group2

uslid1, group3

uslid3, group1

uslid3, group3          etc

the second table2 has three columns

uslid, name, and location

uslid1, john, bldg 4

uslid2, jane, accounting

uslid3, joe, mail room

. I am trying to do a inner join but not working and not sure if this will work to create new temp table.  

example of what i am trying to get in new temp table on one row:

uslid, name, location, groupid1, groupid2, groupid3

uslid1, john, bldg 4, group1, group2, group3

uslid3, joe, mail room, goup1,          , group3

Hope i explained this ok. Im using 2003 server sql 2000 ver 7,  thank you in advance.

 

View 1 Replies View Related

Create Reports In ASP Format?

Sep 5, 2007

We use an internal tool that can display ASP pages. I would like to use SQL Reporting Services to create reports in ASP format. The ASP page will access the database to get data. Is this possible possible with Reporting Services?

Ric

View 2 Replies View Related

Query To Create A Countable List Using A Single Value From Table

Mar 15, 2004

Hi,

from a single numeric value, say 'n', in a field in a table, i'd like to create a SELECT query that produces a list from 1 to n, e.g

if the value was 6, I would like selected back:
1
2
3
4
5
6

Any pointers?
Greg

View 5 Replies View Related

Recovery :: Will AG Listener Create A Single Failure Point

Sep 16, 2015

Assuming all windows servers belonging to the WSFC are on the same subnet, will the AG listener become a single failure point in system if all Application servers connect to the AG through the listener? If the answer is yes, what are the options to resolve this issue?

View 3 Replies View Related

Create Primary Key With Increment And Format?

Nov 19, 2005

I have an access table that has a primary key (entitled "ID Number"), no duplicates, the field is an integer.And, importantly, the value is set to "increment".The format is "phd"000 -  so it starts out phd001, phd002, and so on...How to do this in an SQL table?  Can that format be done?  Or is it better not to do it via SQL but in coding instead?

View 1 Replies View Related

SQL 2012 :: How To Create XML Format File

May 21, 2015

I see this all over for creating a Format file:

bcp Northwind.dbo.Products format nul -c -f "c:Products.fmt" -T

Or this for XML

bcp AdventureWorks.HumanResources.Department format nul -c -x -f department.xml -T -S servername

I get an error saying "cannot open a connection to SQL SERVER"

The SQL Server is local on my laptop.

Here is the exact code I am using:

bcp OrderDb.CompanyDepartment foramt nul -c -x -f c:CompanyDepartment.fmt -t, -T

And I have tried :

bcp OrderDb.CompanyDepartment foramt nul -c -x -f c:CompanyDepartment.xml -t, -T

Also, some say to put the server name at the end, but then I get an unknown argument on command line error

View 1 Replies View Related

Create Trigger To Format Text

Mar 4, 2015

We are using an old version of Numara TrackIT for our helpdesk software, and it doesn't have much in the way of configurable options. There is no way to set validation or formatting on the text fields in the program.

There is a field, WO_TEXT1, Which I would like to be formatted as 6 characters, 3 integers + a period + 2 integers. The first the integers would be padded with zeros on the left, and the last 2 integers would be padded with zeros on the right.

IE, if someone enters 2, it would actually end up being 002.00
If someone enters 3.5 it would end up being 003.50
If someone enters 12.1 it would end up being 012.10
If someone enters 172.80 it would end up being 172.80

I was hoping to achieve this via an update trigger.

Below is the guts of the trigger I created, mostly as a proof of concept.

-- This update properly formats the Estimated Hours field
Update t SET WO_TEXT1 = (SELECT RIGHT('000000' + CONVERT(VARCHAR(6), WO_TEXT1), 6) FROM inserted)
FROM dbo.TASKS as t
Where (EXISTS (SELECT * FROM inserted WHERE WOID = 24773));

I expected that this update trigger would only affect the Work Order with a WOID of 24773. Unfortunately, it updated all 21000 work orders in our system, wiping out all of the actual estimated hours that had been inserted by technicians!

Luckily I had a report that I could quick dump the 300 or so active work order's estimated hours back into the DB from (all the other Work orders are closed, and no one really cares about their estimated hours).

My question is three fold,

1) Why did my trigger update every record in the tasks table instead of just WO 24773?
2) Is using a trigger the best way of accomplishing what I'm trying to do?
3) if a trigger is the best way of accomplishing this, what should my trigger look like?

View 12 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved