473,385 Members | 1,396 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Help with Dynamic SQL

How do I convert the following code into dynamic sql?

Expand|Select|Wrap|Line Numbers
  1. INSERT INTO StagingFinal(col1, col2, 
  2.                          col3,col4, col5, col6, col7, col8)
  3.          SELECT stag.id, 
  4.                 REPLACE(stag.col1,stag.col1,'User' + stag.col1)
  5.               , us.id , ua.Users
  6.              , (CASE WHEN UPPER(Job) = 'Accounting' THEN 0 ELSE 1 END)
  7.               , stag.EndDate , 
  8.                 CONVERT(INT, REPLACE(stag.earnings,'.000',''))
  9.               , stag.rep
  10.          FROM Staging stag , 
  11.                dbo.Users us , 
  12.                dbo.UserAccs ua
  13.          WHERE stag.cus = ''
  14.          AND us.id = ua.id
  15.          AND REPLACE(ua.AccountNumber,'-','') = stag.AccountNumber
  16.  
  17.  
Jun 27 '07 #1
6 1288
DeMan
1,806 1GB
Hi yaaadman,

Welcome to TSDN. As this is a technical question I will move it to a more appropriate forum. In future, you can access this forum by selecting from the options in the dropdownlist from the blue bar near the top of the screen.

I hope the experts can at least point you in the right direction
Jun 27 '07 #2
pbmods
5,821 Expert 4TB
Heya, yaaadman. Welcome to TSDN!

Well, that depends. What variables do you want to insert? What language are you using to program your application?
Jun 27 '07 #3
Heya, yaaadman. Welcome to TSDN!

Well, that depends. What variables do you want to insert? What language are you using to program your application?
The only variable that will change is the first table name in the FROM clause Staging. I basically have a .net console program pass a table name to the stored procedure.
Jun 27 '07 #4
pbmods
5,821 Expert 4TB
Heya, yaaadman.

Alrightey. I've contacted a MySQL moderator to have this thread moved to the .NET forum, where you'll be more likely to find an expert who can help you out.
Jun 27 '07 #5
Heya, yaaadman.

Alrightey. I've contacted a MySQL moderator to have this thread moved to the .NET forum, where you'll be more likely to find an expert who can help you out.
I will post in the SQL Server forum. You can have the moderator just delete this thread
Jun 27 '07 #6
Atli
5,058 Expert 4TB
As you have already posted a new thread in the SQL Server forums, and this is kind of MySQL related, I will leave the thread as it is and just close it.

All new replies to this thread should be posted in the new thread located here, in the SQL Server forums.

Moderator
Jun 27 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Marc | last post by:
Hello, I've fiddled with this for quite a while and thought I had the problem solved. I had a version that would successfully compile and run. But then I had to change the code to use a...
14
by: Stuart D. Gathman | last post by:
I have a function that recognizes PTR records for dynamic IPs. There is no hard and fast rule for this - every ISP does it differently, and may change their policy at any time, and use different...
10
by: Bob Rock | last post by:
Hello, is there a way to turn off dynamic help from displaying when clicking F1??? Every time I call help on a word the external MSDN opens up (just as I want) BUT also the dynamic pane inside...
0
by: Pat Patterson | last post by:
I'm having serious issues with a page I'm developing. I just need some simple help, and was hoping someone might be able to help me out in here. I have a form, that consists of 3 pages of...
5
by: Steve | last post by:
I have written a help file (chm) for a DLL and referenced it using Help.ShowHelp My expectation is that a developer using my DLL would be able to access this help file during his development time...
83
by: deppy_3 | last post by:
Hi.I am started learning Programm language C before some time.I am trying to make a programm about a very simple "sell shop".This programm hasn't got any compile problem but when i run it i face...
8
by: Dip | last post by:
Hello Experts, Here is the code to flatten a PC hierarchy into a level based table. It works fine. SELECT t1.TASK_ID AS TASK_LV1, t2.TASK_ID AS TASK_LV2, t3.TASK_ID AS TASK_LV3, t4.TASK_ID AS...
30
by: Alf P. Steinbach | last post by:
I once suggested in that SomeOne Else(TM) should propose a string value class that accepted literals and char pointers and so on, with possible custom deleter, and in case of literal strings just...
3
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, If I open the Dynamic help window in VS, why it doesn't show anything when I move a mouse to a system class say, dictionary. it says "No links are available for the current select"....
0
by: richard12345 | last post by:
Hi Guys I have problem with site I am building. The sidebar with menu and other thinks is overlapping footer. The footer move with the content and but it dos it dos not move with the sidebar. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.