Hello,
I’m trying to create a Calendar Table in SQL to fill dates gaps. I’m basically trying to build a table for 108 zip codes for a specific date range.
Current workflow:
-
Database connect
-
Execute Query - Create a distinct list of 108 zip codes and store in Data table
variable.
dt_Zip
-
For Each row in Data Table dt_Zip
Execute SQL Query - the query creates the date range with Zip code
variable
**dt_Out**
-
Insert dt_Out data table variable into SQL table.
I’m struggling to set the @Zip variable in SQL query from the dt_Zip
Set @Zip = row(““Zipcode””).ToString
I keep getting SQL compile errors with sting needs double quotes.
Any help would be greatly appreciated.
Thanks,
Tim
postwick
(Paul)
2
The proper SQL query would be…
INSERT INTO [tablename]([columnname1],[columname2]) VALUES ('column1value','column2value')
So if you want to replace one of those with a variable…
"INSERT INTO [tablename]([columnname1],[columname2]) VALUES ('" + yourVariable + "','column2value')
The problem is you’re using double quotes incorrectly for SQL.
Hi Paul,
I’m struggling to set the variable not the insert.
The variable is being set during a For Each Row of Data table loop. For Each Row in dt_zips
I thought the row function would set the variable from dt_zips. ZIPCODE is name of column in dt_zips
Set @Zip = ‘" +row(" ZIPCODE").ToString+"’
Hi still get compile errors
postwick
(Paul)
7
Set is for update queries. Why are you trying to set a SQL variable?
Hello @timothy.mullady
Try to pass it as a parameter instead
Thanks,
Prankur
I’m trying to change the query result for each run in the loop
postwick
(Paul)
10
You need to give more detail, this doesn’t really help us understand what your goal is.
system
(system)
Closed
12
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.